Skip to content

Commit

Permalink
Add .runsettings file to be able to run and debug tests on vscode in …
Browse files Browse the repository at this point in the history
…codespace with prebuilt (#61684)
  • Loading branch information
safern authored Nov 16, 2021
1 parent 8076522 commit c66fa99
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@

"settings": {
// Loading projects on demand is better for larger codebases
"omnisharp.enableMsBuildLoadProjectsOnDemand": true
"omnisharp.enableMsBuildLoadProjectsOnDemand": true,
"omnisharp.enableRoslynAnalyzers": true,
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableAsyncCompletion": true,
"omnisharp.testRunSettings": "${containerWorkspaceFolder}/artifacts/obj/vscode/.runsettings"
},

// Add the IDs of extensions you want installed when the container is created.
Expand Down
2 changes: 2 additions & 0 deletions .devcontainer/scripts/onCreateCommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -e

# prebuild the repo, so it is ready for development
./build.sh libs+clr -rc Release
# restore libs tests so that the project is ready to be loaded by OmniSharp
./build.sh libs.tests -restore

# save the commit hash of the currently built assemblies, so developers know which version was built
git rev-parse HEAD > ./artifacts/prebuild.sha
7 changes: 7 additions & 0 deletions eng/testing/runsettings.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<CreateIntermediateRunSettingsFile Condition="'$(CreateIntermediateRunSettingsFile)' == ''">false</CreateIntermediateRunSettingsFile>
<RunSettingsOutputFilePath Condition="'$(CreateIntermediateRunSettingsFile)' == 'true'">$(RunSettingsIntermediateOutputFilePath)</RunSettingsOutputFilePath>
<RunSettingsOutputFilePath Condition="'$(CreateIntermediateRunSettingsFile)' != 'true'">$(RunSettingsAppOutputFilePath)</RunSettingsOutputFilePath>
<VsCodeRunSettingsOutputFilePath>$(ArtifactsObjDir)vscode/.runsettings</VsCodeRunSettingsOutputFilePath>

<!-- Set RunSettingsFilePath property which is read by VSTest. -->
<RunSettingsFilePath Condition="Exists('$(RunSettingsAppOutputFilePath)')">$(RunSettingsAppOutputFilePath)</RunSettingsFilePath>
Expand Down Expand Up @@ -46,6 +47,12 @@
WriteOnlyWhenDifferent="true"
Overwrite="true" />

<WriteLinesToFile File="$(VsCodeRunSettingsOutputFilePath)"
Lines="$(RunSettingsFileContent)"
WriteOnlyWhenDifferent="true"
Overwrite="true"
Condition="'$(CreateVsCodeRunSettingsFile)' == 'true'" />

<!-- Set RunSettingsFilePath property which is read by VSTest. -->
<PropertyGroup>
<RunSettingsFilePath>$(RunSettingsOutputFilePath)</RunSettingsFilePath>
Expand Down
1 change: 1 addition & 0 deletions src/libraries/pretest.proj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<!-- Create an intermediate runsettings file to enable VSTest discovery. -->
<EnableRunSettingsSupport>true</EnableRunSettingsSupport>
<CreateIntermediateRunSettingsFile>true</CreateIntermediateRunSettingsFile>
<CreateVsCodeRunSettingsFile>true</CreateVsCodeRunSettingsFile>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit c66fa99

Please sign in to comment.