Skip to content

Commit

Permalink
Update dotnet.cake
Browse files Browse the repository at this point in the history
Update dotnet.cake

Set env variables before build  device tests

Update DotnetInternal.cs

Update dotnet.cake
  • Loading branch information
rmarinho committed Feb 2, 2024
1 parent 70dff82 commit 0fa8b78
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
5 changes: 3 additions & 2 deletions eng/cake/dotnet.cake
Original file line number Diff line number Diff line change
Expand Up @@ -543,16 +543,17 @@ Dictionary<string, string> GetDotNetEnvironmentVariables()

}

void SetDotNetEnvironmentVariables()
void SetDotNetEnvironmentVariables(string dotnetDir = null)
{
var dotnet = MakeAbsolute(Directory("./bin/dotnet/")).ToString();
var dotnet = dotnetDir ?? MakeAbsolute(Directory("./bin/dotnet/")).ToString();

SetEnvironmentVariable("VSDebugger_ValidateDotnetDebugLibSignatures", "0");
SetEnvironmentVariable("DOTNET_INSTALL_DIR", dotnet);
SetEnvironmentVariable("DOTNET_ROOT", dotnet);
SetEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR", dotnet);
SetEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0");
SetEnvironmentVariable("MSBuildEnableWorkloadResolver", "true");
SetEnvironmentVariable("ForceNet8Current", "true");
SetEnvironmentVariable("PATH", dotnet, prepend: true);

// Get "full" .binlog in Project System Tools
Expand Down
12 changes: 0 additions & 12 deletions eng/cake/helpers.cake
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,6 @@ public void PrintEnvironmentVariables()
};
}

void SetDotNetEnvironmentVariables(string dotnetDir)
{
var dotnet = dotnetDir ?? MakeAbsolute(Directory("./bin/dotnet/")).ToString();

SetEnvironmentVariable("DOTNET_INSTALL_DIR", dotnet);
SetEnvironmentVariable("DOTNET_ROOT", dotnet);
SetEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR", dotnet);
SetEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0");
SetEnvironmentVariable("MSBuildEnableWorkloadResolver", "true");
SetEnvironmentVariable("PATH", dotnet, prepend: true);
}

void SetEnvironmentVariable(string name, string value, bool prepend = false)
{
var target = EnvironmentVariableTarget.Process;
Expand Down
1 change: 1 addition & 0 deletions eng/devices/android.cake
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ Task("Build")
.WithCriteria(!string.IsNullOrEmpty(PROJECT.FullPath))
.Does(() =>
{
SetDotNetEnvironmentVariables();
var name = System.IO.Path.GetFileNameWithoutExtension(PROJECT.FullPath);
var binlog = $"{BINLOG_DIR}/{name}-{CONFIGURATION}-android--{DateTime.UtcNow.ToFileTimeUtc()}.binlog";
Expand Down
7 changes: 4 additions & 3 deletions eng/devices/catalyst.cake
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Task("Build")
.WithCriteria(!string.IsNullOrEmpty(PROJECT.FullPath))
.Does(() =>
{
SetDotNetEnvironmentVariables();
var name = System.IO.Path.GetFileNameWithoutExtension(PROJECT.FullPath);
var binlog = $"{BINLOG_DIR}/{name}-{CONFIGURATION}-catalyst.binlog";
Expand Down Expand Up @@ -111,17 +113,16 @@ Task("Test")
Information("Test Results Directory: {0}", TEST_RESULTS);
if (!IsCIBuild())
{
CleanDirectories(TEST_RESULTS);
}
else
{
// Because we retry on CI we don't want to delete the previous failures
// We want to publish those files for reference
DeleteFiles(Directory(TEST_RESULTS).Path.Combine("*.*").FullPath);
//SetDotNetEnvironmentVariables("/Users/runner/hostedtoolcache/dotnet");
}
var settings = new DotNetToolSettings {
DiagnosticOutput = true,
ToolPath = DOTNET_TOOL_PATH,
Expand Down
2 changes: 2 additions & 0 deletions eng/devices/ios.cake
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ Task("Build")
.WithCriteria(!string.IsNullOrEmpty(PROJECT.FullPath))
.Does(() =>
{
SetDotNetEnvironmentVariables();
var name = System.IO.Path.GetFileNameWithoutExtension(PROJECT.FullPath);
var binlog = $"{BINLOG_DIR}/{name}-{CONFIGURATION}-ios.binlog";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public static string RunForOutput(string command, string args, out int exitCode,
var pinfo = new ProcessStartInfo(DotnetTool, $"{command} {args}");
pinfo.EnvironmentVariables["DOTNET_MULTILEVEL_LOOKUP"] = "0";
pinfo.EnvironmentVariables["DOTNET_ROOT"] = DotnetRoot;
pinfo.EnvironmentVariables["ForceNet8Current"] = "true";

return ToolRunner.Run(pinfo, out exitCode, timeoutInSeconds: timeoutInSeconds);
}
Expand Down

0 comments on commit 0fa8b78

Please sign in to comment.