Skip to content

Commit 7435114

Browse files
mauroaGitHub Actions Autoformatter
andauthored
[messaging] Fixed environment variables logic on Build Agent (#23676)
We were setting a custom home folder (.home directory defined in the DOTNET_CUSTOM_HOME env var) when the dotnet SDK was installed by Pair To Mac, to encapsulate caches and to not mix them with the global dotnet installation: https://github.com/dotnet/macios/blob/main/msbuild/Messaging/Xamarin.Messaging.Build/TaskRunner.cs#L62C4-L66C6 If the user assigns the global dotnet installation to the "_DotNetRootRemoteDirectory" MSBuild property, the Build agent will end up overriding the HOME folder with a custom home that doesn't exist (there's no .home folder in the user profile in the Mac (where dotnet installs the global caches). This issue has been revealed from the recent changes that allows the MSBuild client to bypass the "_DotNetRootRemoteDirectory" property to the Build Agent: https://dev.azure.com/devdiv/DevDiv/_git/ClientTools.Platform/pullrequest/663026 The fix consists of setting the custom home only if the dotnet SDK path to use is not the global one --------- Co-authored-by: GitHub Actions Autoformatter <[email protected]>
1 parent 6602e24 commit 7435114

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

msbuild/Messaging/Xamarin.Messaging.Build/TaskRunner.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,19 @@ void SetDotNetVariables ()
6060
var xmaDotNetPath = default (string);
6161

6262
if (IsValidDotNetInstallation (xmaDotNetRootPath)) {
63-
//If the XMA dotnet is already installed, we use it and also declare a custom home for it (for NuGet restore and caches)
64-
Environment.SetEnvironmentVariable ("DOTNET_CUSTOM_HOME", Path.Combine (xmaSdkRootPath, ".home"));
6563
xmaDotNetPath = GetDotNetPath (xmaDotNetRootPath);
6664
} else {
6765
//In case the XMA dotnet has not been installed yet, we use the default dotnet installation
6866
xmaDotNetPath = GetDefaultDotNetPath ();
6967
xmaDotNetRootPath = Path.GetDirectoryName (xmaDotNetPath);
7068
}
7169

70+
//We want to define a custom home for dotnet only if it's the Pair To Mac SDK installation
71+
if (xmaDotNetRootPath.StartsWith (MessagingContext.BasePath, StringComparison.OrdinalIgnoreCase)) {
72+
//The custom home is used for storing caches and not mix them with the global installation (NuGet, dotnet, etc.)
73+
Environment.SetEnvironmentVariable ("DOTNET_CUSTOM_HOME", Path.Combine (xmaSdkRootPath, ".home"));
74+
}
75+
7276
var pathContent = GetPathContent ();
7377
//We add the XMA dotnet path first so it has priority over the default dotnet installation
7478
var newPathContent = $"{xmaDotNetRootPath}:{pathContent}";

0 commit comments

Comments
 (0)