-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add App Host Support for MSBuild #13175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
531d264
add apphost support
YuliiaKovalova 2e623d0
add e2e tests
YuliiaKovalova 072cb7b
fix the tests
YuliiaKovalova d023200
avoid target framework hardcoding in codebase
YuliiaKovalova 96159c0
exclude adding source build
YuliiaKovalova d2d33a6
fix the test
YuliiaKovalova 95f4da2
revert the condition
YuliiaKovalova 68880eb
fix the tests
YuliiaKovalova ad34e84
Merge branch 'main' into dev/ykovalova/app_host_support
YuliiaKovalova 16ac07f
Merge remote-tracking branch 'origin/main' into dev/ykovalova/app_hos…
YuliiaKovalova 5b0b950
Merge branch 'dev/ykovalova/app_host_support' of https://github.com/d…
YuliiaKovalova 0fd74ed
fix review commet
YuliiaKovalova 1e5e8c3
fix the issue
YuliiaKovalova fc15e94
undo changes in tests
YuliiaKovalova d2004c9
undo more change
YuliiaKovalova 0d3288f
fix the tests
YuliiaKovalova 011735e
more test fixes
YuliiaKovalova 4daad92
more test fixes
YuliiaKovalova fb8eb1e
fix a typo
YuliiaKovalova 72bbf09
Update cibuild_bootstrapped_msbuild.ps1
YuliiaKovalova e9a28f6
update build env helper
YuliiaKovalova e517aa0
Merge branch 'dev/ykovalova/app_host_support' of https://github.com/d…
YuliiaKovalova 6aaadfb
various fixes around tests + use app host on repo build
YuliiaKovalova 4812435
return smaller timeout
YuliiaKovalova cfeb1f5
fix some of review comments
YuliiaKovalova db70e68
refactor nodelauncher
YuliiaKovalova 7612dea
merge
YuliiaKovalova 60c2d79
fix the tests
YuliiaKovalova cbe4fff
fix the tests and avoid hardcoded app name
YuliiaKovalova b9d8d49
more changes around tests and logic
YuliiaKovalova 07e999a
merge
YuliiaKovalova 0d7153f
fix the last tests in BuildManager
YuliiaKovalova 7433663
fix the comments
YuliiaKovalova ffbbf48
merge
YuliiaKovalova 8b1070e
fix review comment
YuliiaKovalova c992bc9
fix nullability
YuliiaKovalova 6f7ce52
try to revert condition
YuliiaKovalova 34b7f33
undo extra changes in tests (?)
YuliiaKovalova 6c71b1b
fix review comments
YuliiaKovalova 0c89f3c
Merge remote-tracking branch 'origin/main' into dev/ykovalova/app_hos…
YuliiaKovalova afe69cb
Remove .dll.config/.exe.config special case
rainersigwald 4c78263
Simplify XSD logic
rainersigwald 053267f
nit: fix indentation
rainersigwald 7ac345b
SupportedOSPlatform in NodeLauncher
rainersigwald e7e6e2d
include output
rainersigwald a7d3b23
Keep looking for MSBuild.dll.config on core
rainersigwald 86063a3
Simplify NetTaskHostTest_AppHostUsedWhenAvailable
rainersigwald 5d9d7a9
Be explicit about config file name
rainersigwald 2f8faad
fix the failing test
YuliiaKovalova 0c305bd
add .ToLowerInvariant()
YuliiaKovalova bf5f9d7
merge + fix for Unix build
YuliiaKovalova ef893fe
merge
YuliiaKovalova 7cbb0f2
merge
YuliiaKovalova 0dae95d
fixx null ref
YuliiaKovalova 3811ee8
Merge remote-tracking branch 'upstream/main' into dev/ykovalova/app_h…
rainersigwald 2c19de4
fix the failure
YuliiaKovalova 442f453
Merge branch 'main' into dev/ykovalova/app_host_support
YuliiaKovalova b459f9c
remove extra property
YuliiaKovalova 1726a4e
Merge branch 'dev/ykovalova/app_host_support' of https://github.com/d…
YuliiaKovalova f9e027c
Merge branch 'main' into dev/ykovalova/app_host_support
baronfel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using Microsoft.Build.BackEnd; | ||
| using Microsoft.Build.Internal; | ||
| using Microsoft.Build.Shared; | ||
| using Microsoft.Build.UnitTests; | ||
| using Shouldly; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| #nullable disable | ||
|
|
||
| namespace Microsoft.Build.Engine.UnitTests.BackEnd | ||
| { | ||
| /// <summary> | ||
| /// Tests for MSBuild App Host support functionality. | ||
| /// Tests the DOTNET_ROOT environment variable handling for app host bootstrap. | ||
| /// </summary> | ||
| public sealed class AppHostSupport_Tests | ||
| { | ||
| private readonly ITestOutputHelper _output; | ||
|
|
||
| private readonly string _dotnetHostPath = NativeMethodsShared.IsWindows | ||
| ? @"C:\Program Files\dotnet\dotnet.exe" | ||
| : "/usr/share/dotnet/dotnet"; | ||
|
|
||
| public AppHostSupport_Tests(ITestOutputHelper output) | ||
| { | ||
| _output = output; | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CreateDotnetRootEnvironmentOverrides_SetsDotnetRootFromHostPath() | ||
| { | ||
| var overrides = DotnetHostEnvironmentHelper.CreateDotnetRootEnvironmentOverrides(_dotnetHostPath); | ||
|
|
||
| overrides.ShouldNotBeNull(); | ||
| overrides.ShouldContainKey("DOTNET_ROOT"); | ||
|
|
||
| string expectedDotnetRoot = Path.GetDirectoryName(_dotnetHostPath); | ||
| overrides["DOTNET_ROOT"].ShouldBe(expectedDotnetRoot); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CreateDotnetRootEnvironmentOverrides_ClearsArchitectureSpecificVariables() | ||
| { | ||
| var overrides = DotnetHostEnvironmentHelper.CreateDotnetRootEnvironmentOverrides(_dotnetHostPath); | ||
|
|
||
| // Assert - architecture-specific variables should be set to null (to be cleared) | ||
| overrides.ShouldContainKey("DOTNET_ROOT_X64"); | ||
| overrides["DOTNET_ROOT_X64"].ShouldBeNull(); | ||
|
|
||
| overrides.ShouldContainKey("DOTNET_ROOT_X86"); | ||
| overrides["DOTNET_ROOT_X86"].ShouldBeNull(); | ||
|
|
||
| overrides.ShouldContainKey("DOTNET_ROOT_ARM64"); | ||
| overrides["DOTNET_ROOT_ARM64"].ShouldBeNull(); | ||
| } | ||
|
|
||
|
|
||
| [WindowsOnlyTheory] | ||
| [InlineData(@"C:\custom\sdk\dotnet.exe", @"C:\custom\sdk")] | ||
| [InlineData(@"D:\tools\dotnet\dotnet.exe", @"D:\tools\dotnet")] | ||
| public void CreateDotnetRootEnvironmentOverrides_HandlesVariousPaths_Windows(string hostPath, string expectedRoot) | ||
| { | ||
| var overrides = DotnetHostEnvironmentHelper.CreateDotnetRootEnvironmentOverrides(hostPath); | ||
|
|
||
| overrides["DOTNET_ROOT"].ShouldBe(expectedRoot); | ||
| } | ||
|
|
||
| [UnixOnlyTheory] | ||
| [InlineData("/usr/local/share/dotnet/dotnet", "/usr/local/share/dotnet")] | ||
| [InlineData("/home/user/.dotnet/dotnet", "/home/user/.dotnet")] | ||
| public void CreateDotnetRootEnvironmentOverrides_HandlesVariousPaths_Unix(string hostPath, string expectedRoot) | ||
| { | ||
| var overrides = DotnetHostEnvironmentHelper.CreateDotnetRootEnvironmentOverrides(hostPath); | ||
|
|
||
| overrides["DOTNET_ROOT"].ShouldBe(expectedRoot); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ClearBootstrapDotnetRootEnvironment_ClearsVariablesNotInOriginalEnvironment() | ||
| { | ||
| using (TestEnvironment env = TestEnvironment.Create(_output)) | ||
| { | ||
| // Arrange - set DOTNET_ROOT variants that simulate app host bootstrap | ||
| env.SetEnvironmentVariable("DOTNET_ROOT", @"C:\TestDotnet"); | ||
| env.SetEnvironmentVariable("DOTNET_ROOT_X64", @"C:\TestDotnetX64"); | ||
|
|
||
| // Original environment does NOT have these variables | ||
| var originalEnvironment = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); | ||
|
|
||
| DotnetHostEnvironmentHelper.ClearBootstrapDotnetRootEnvironment(originalEnvironment); | ||
|
|
||
| Environment.GetEnvironmentVariable("DOTNET_ROOT").ShouldBeNull(); | ||
| Environment.GetEnvironmentVariable("DOTNET_ROOT_X64").ShouldBeNull(); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ClearBootstrapDotnetRootEnvironment_PreservesVariablesInOriginalEnvironment() | ||
| { | ||
| using (TestEnvironment env = TestEnvironment.Create(_output)) | ||
| { | ||
| // Arrange - set DOTNET_ROOT that was in the original environment | ||
| string originalValue = @"C:\OriginalDotnet"; | ||
| env.SetEnvironmentVariable("DOTNET_ROOT", originalValue); | ||
|
|
||
| // Register other DOTNET_ROOT variants with TestEnvironment so cleanup works correctly. | ||
| // These will be cleared by the helper if not in originalEnvironment. | ||
| env.SetEnvironmentVariable("DOTNET_ROOT_X64", null); | ||
| env.SetEnvironmentVariable("DOTNET_ROOT_X86", null); | ||
| env.SetEnvironmentVariable("DOTNET_ROOT_ARM64", null); | ||
|
|
||
| // Original environment HAS DOTNET_ROOT | ||
| var originalEnvironment = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) | ||
| { | ||
| ["DOTNET_ROOT"] = originalValue | ||
| }; | ||
|
|
||
| DotnetHostEnvironmentHelper.ClearBootstrapDotnetRootEnvironment(originalEnvironment); | ||
|
|
||
| // Assert - DOTNET_ROOT should be preserved since it was in original environment | ||
| Environment.GetEnvironmentVariable("DOTNET_ROOT").ShouldBe(originalValue); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ClearBootstrapDotnetRootEnvironment_HandlesMixedScenario() | ||
| { | ||
| using (TestEnvironment env = TestEnvironment.Create(_output)) | ||
| { | ||
| string originalDotnetRoot = @"C:\OriginalDotnet"; | ||
| string bootstrapX64 = @"C:\BootstrapX64"; | ||
|
|
||
| env.SetEnvironmentVariable("DOTNET_ROOT", originalDotnetRoot); | ||
| env.SetEnvironmentVariable("DOTNET_ROOT_X64", bootstrapX64); | ||
| env.SetEnvironmentVariable("DOTNET_ROOT_X86", @"C:\BootstrapX86"); | ||
|
|
||
| // Original environment has DOTNET_ROOT but not the architecture-specific ones | ||
| var originalEnvironment = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) | ||
| { | ||
| ["DOTNET_ROOT"] = originalDotnetRoot | ||
| }; | ||
|
|
||
| DotnetHostEnvironmentHelper.ClearBootstrapDotnetRootEnvironment(originalEnvironment); | ||
|
|
||
| Environment.GetEnvironmentVariable("DOTNET_ROOT").ShouldBe(originalDotnetRoot); // Preserved | ||
| Environment.GetEnvironmentVariable("DOTNET_ROOT_X64").ShouldBeNull(); // Cleared | ||
| Environment.GetEnvironmentVariable("DOTNET_ROOT_X86").ShouldBeNull(); // Cleared | ||
| Environment.GetEnvironmentVariable("DOTNET_ROOT_ARM64").ShouldBeNull(); // Was already null | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.