Improve debugging experience / Automatically set debugger options #147
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves issues #18 and #19.
The main goal of this PR is to improve the debugging experience of ExcelDna add-ins by automatically detecting the latest Excel version installed on the machine, as well as Excel's bitness (i.e. 32-bit or 64-bit), and set the debugger options in the project where ExcelDna.AddIn is installed, on every build, to the Excel detected, and the right add-in (32 or 64) to be opened with Excel.
This PR allows the following user experiences:
Start debugging an add-in immediately after downloading code from source control, regardless of the Excel version that the original developer was using, without having to define any setting in the project debug configuration;
Start debugging an add-in immediately after renaming the
.dna
file, without having to change any setting in the project configuration (as it automatically updates the debug settings with the new.xll
file name);Start debugging an add-in immediately after changing suffixes for add-ins in the
ExcelDna.Build.props
file, without having to change any setting in the project configuration (as it automatically updates the debug settings with the new.xll
file name);Dynamically target different Excel installations on the machine via conditions in
ExcelDna.Build.props
.How to override the default behavior
The
ExcelDna.Build.props
that gets added into theProperties
folder of the add-in, includes three (3) new variables:RunExcelDnaSetDebuggerOptions
- Allows the user to turn off/on setting the debug options during build;ExcelDnaExcelExePath
- Allows the user to override the default behavior of using the most recent version of Excel installed on the machine, and instead use a particular Excel installation, by providing the full path of the EXCEL.EXE that should be used;ExcelDnaAddInForDebugging
- Allows the user to override the default behavior of using the add-in that matches the EXCEL.EXE bitness (i.e. 32-bit or 64-bit), and instead use a particular add-in, by providing the file name of the.xll
file that should be passed to EXCEL.EXE as an argument.Of course, ideally users would use the variables above only for tests during debugging sessions, and change them back to their original values before committing the
ExcelDna.Build.props
file to source control, as changes to these variables would impact the user experiences described earlier above.I tested this PR with C#, VB .NET, and F# projects on Visual Studio 2017 (Enterprise and Community) as well as Visual Studio 2015 (Enterprise), and would welcome any further testing.
/cc @govert, @garethhayter, @konne