Skip to content

Commit be3d74f

Browse files
committed
Use the same SDK version as the runtime
1 parent c2ea4bd commit be3d74f

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "MSBuildLocator"]
2+
path = MSBuildLocator
3+
url = https://github.com/TMC-C/MSBuildLocator
4+
branch = get-all-installed-dotnetsdk-instances

Bootstrap/Bootstrap.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.Build.Locator" Version="1.2.6" />
1211
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20253.1" />
1312
</ItemGroup>
1413

1514
<ItemGroup>
1615
<ProjectReference Include="..\Core\Core.csproj" />
16+
<ProjectReference Include="..\MSBuildLocator\src\MSBuildLocator\Microsoft.Build.Locator.csproj" />
1717
</ItemGroup>
1818

1919
</Project>

Bootstrap/Program.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,16 @@ private static bool FindMsBuild()
138138
return true;
139139
}
140140

141-
VisualStudioInstance? vsInstance = MSBuildLocator.RegisterDefaults();
141+
VisualStudioInstance? vsInstance = MSBuildLocator.QueryVisualStudioInstances(VisualStudioInstanceQueryOptions.Default)
142+
.FirstOrDefault(i => i.Version.Major == Environment.Version.Major && i.Version.Minor == Environment.Version.Minor);
142143
if (!(vsInstance is null))
143144
{
145+
MSBuildLocator.RegisterInstance(vsInstance);
146+
144147
return true;
145148
}
146149

147-
Console.WriteLine("No environment variable MSBUILD_EXE_PATH has been set and we were unable to locate it automatically!");
150+
Console.WriteLine($"No environment variable MSBUILD_EXE_PATH has been set and we were unable to locate it automatically! You need to install SDK for {Environment.Version.ToString(2)}");
148151

149152
return false;
150153
}

MSBuildLocator

Submodule MSBuildLocator added at a101a03

TMC-CSharp-Runner.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bootstrap", "Bootstrap\Boot
99
EndProject
1010
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API", "API\API.csproj", "{43B2D155-CBE9-407E-9EE6-60170BFCB33D}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{F4199101-8840-4616-A25D-869E5F0C2B27}"
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{F4199101-8840-4616-A25D-869E5F0C2B27}"
1313
EndProject
14-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAssembly", "TestAssembly\TestAssembly.csproj", "{A350F515-23AB-4288-8972-800E05261642}"
14+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestAssembly", "TestAssembly\TestAssembly.csproj", "{A350F515-23AB-4288-8972-800E05261642}"
15+
EndProject
16+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Build.Locator", "MSBuildLocator\src\MSBuildLocator\Microsoft.Build.Locator.csproj", "{342FF612-37EC-41B4-BB5F-CD6A52D5C32E}"
1517
EndProject
1618
Global
1719
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -39,6 +41,10 @@ Global
3941
{A350F515-23AB-4288-8972-800E05261642}.Debug|Any CPU.Build.0 = Debug|Any CPU
4042
{A350F515-23AB-4288-8972-800E05261642}.Release|Any CPU.ActiveCfg = Release|Any CPU
4143
{A350F515-23AB-4288-8972-800E05261642}.Release|Any CPU.Build.0 = Release|Any CPU
44+
{342FF612-37EC-41B4-BB5F-CD6A52D5C32E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45+
{342FF612-37EC-41B4-BB5F-CD6A52D5C32E}.Debug|Any CPU.Build.0 = Debug|Any CPU
46+
{342FF612-37EC-41B4-BB5F-CD6A52D5C32E}.Release|Any CPU.ActiveCfg = Release|Any CPU
47+
{342FF612-37EC-41B4-BB5F-CD6A52D5C32E}.Release|Any CPU.Build.0 = Release|Any CPU
4248
EndGlobalSection
4349
GlobalSection(SolutionProperties) = preSolution
4450
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)