From 88b8fc6b330fa8318efad32c3663257586156f9b Mon Sep 17 00:00:00 2001
From: Manish Godse <61718172+mangod9@users.noreply.github.com>
Date: Fri, 11 Jun 2021 21:11:16 -0700
Subject: [PATCH 1/7] replace crossgen with crossgen2
crossgen is now defunct. This is validated on windows x64. More work will be required to get it to work across OS/arch.
---
src/core-sdk-tasks/Crossgen.cs | 41 +++++++++++++----------------
src/redist/targets/Crossgen.targets | 5 ++--
2 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/src/core-sdk-tasks/Crossgen.cs b/src/core-sdk-tasks/Crossgen.cs
index eb173d3c6..4aca9c60e 100644
--- a/src/core-sdk-tasks/Crossgen.cs
+++ b/src/core-sdk-tasks/Crossgen.cs
@@ -41,8 +41,6 @@ namespace Microsoft.DotNet.Build.Tasks
private string TempOutputPath { get; set; }
- private bool _secondInvocationToCreateSymbols;
-
protected override bool ValidateParameters()
{
base.ValidateParameters();
@@ -67,7 +65,15 @@ namespace Microsoft.DotNet.Build.Tasks
if (toolResult)
{
- File.Copy(TempOutputPath, DestinationPath, overwrite: true);
+ var files = System.IO.Directory.GetFiles(Path.GetDirectoryName(TempOutputPath));
+ var dest = Path.GetDirectoryName(DestinationPath);
+ // Copy both dll and pdb files to the destination folder
+ foreach(var file in files)
+ {
+ File.Copy(file, $"{dest}{Path.GetFileName(file)}", overwrite: true);
+ // Delete file in temp
+ File.Delete(file);
+ }
}
if (File.Exists(TempOutputPath))
@@ -76,18 +82,12 @@ namespace Microsoft.DotNet.Build.Tasks
}
Directory.Delete(tempDirPath);
- if (toolResult && CreateSymbols)
- {
- _secondInvocationToCreateSymbols = true;
- toolResult = base.Execute();
- }
-
return toolResult;
}
protected override string ToolName
{
- get { return "crossgen"; }
+ get { return "crossgen2"; }
}
protected override MessageImportance StandardOutputLoggingImportance
@@ -133,23 +133,18 @@ namespace Microsoft.DotNet.Build.Tasks
return CrossgenPath;
}
- return "crossgen";
+ return "crossgen2";
}
protected override string GenerateCommandLineCommands()
{
- if (_secondInvocationToCreateSymbols)
- {
- return $"{GetReadyToRun()} {GetPlatformAssemblyPaths()} {GetDiasymReaderPath()} {GetCreateSymbols()}";
- }
-
- return $"{GetReadyToRun()} {GetMissingDependenciesOk()} {GetInPath()} {GetOutPath()} {GetPlatformAssemblyPaths()} {GetJitPath()}";
+ return $"{GetInPath()} {GetOutPath()} {GetPlatformAssemblyPaths()} {GetCreateSymbols()}";
}
private string GetCreateSymbols()
{
- var option = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "-createpdb" : "-createperfmap";
- return $"{option} \"{Path.GetDirectoryName(DestinationPath)}\" \"{DestinationPath}\"";
+ var option = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "--pdb" : "--perfmap";
+ return $"{option}";
}
private string GetDiasymReaderPath()
@@ -174,12 +169,12 @@ namespace Microsoft.DotNet.Build.Tasks
private string GetInPath()
{
- return $"-in \"{SourceAssembly}\"";
+ return $" \"{SourceAssembly}\"";
}
private string GetOutPath()
{
- return $"-out \"{TempOutputPath}\"";
+ return $"-o \"{TempOutputPath}\"";
}
private string GetPlatformAssemblyPaths()
@@ -190,11 +185,11 @@ namespace Microsoft.DotNet.Build.Tasks
{
foreach (var excludeTaskItem in PlatformAssemblyPaths)
{
- platformAssemblyPaths += $"{excludeTaskItem.ItemSpec}{Path.PathSeparator}";
+ platformAssemblyPaths += $"-r {excludeTaskItem.ItemSpec}{Path.DirectorySeparatorChar}*.dll ";
}
}
- return $" -platform_assemblies_paths {platformAssemblyPaths.Trim(':')}";
+ return platformAssemblyPaths;
}
private string GetJitPath()
diff --git a/src/redist/targets/Crossgen.targets b/src/redist/targets/Crossgen.targets
index 3561d2031..73a4ebda9 100644
--- a/src/redist/targets/Crossgen.targets
+++ b/src/redist/targets/Crossgen.targets
@@ -5,10 +5,11 @@
microsoft.netcore.app.runtime.$(SharedFrameworkRid)
+ Microsoft.NETCore.App.Crossgen2.$(SharedFrameworkRid)
<_crossDir Condition="'$(Architecture)' == 'arm64' and '$(BuildArchitecture)' != 'arm64'">/x64_arm64
<_crossDir Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'win'">/x86_arm
<_crossDir Condition="'$(Architecture)' == 'arm' And '$(OSName)' != 'win'">/x64_arm
- $(NuGetPackageRoot)/$(RuntimeNETCoreAppPackageName)/$(MicrosoftNETCoreAppRuntimePackageVersion)/tools$(_crossDir)/crossgen$(ExeExtension)
+ $(NuGetPackageRoot)/$(RuntimeNETCrossgenPackageName)/$(MicrosoftNETCoreAppRuntimePackageVersion)/tools/crossgen2$(ExeExtension)
x64_arm64
x86_arm
x64_arm
@@ -24,7 +25,7 @@
- PackageToRestore=$(RuntimeNETCoreAppPackageName);
+ PackageToRestore=$(RuntimeNETCrossgenPackageName);
PackageVersionToRestore=$(MicrosoftNETCoreAppRuntimePackageVersion);
TargetFramework=$(TargetFramework)
From ed9c92df3aef85222bb0fc6d4746ec2cdd66f7cf Mon Sep 17 00:00:00 2001
From: Manish Godse <61718172+mangod9@users.noreply.github.com>
Date: Fri, 11 Jun 2021 21:25:25 -0700
Subject: [PATCH 2/7] propagate targetArch to crossgen2
---
src/core-sdk-tasks/Crossgen.cs | 14 +++++++-------
src/redist/targets/Crossgen.targets | 6 +++---
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/core-sdk-tasks/Crossgen.cs b/src/core-sdk-tasks/Crossgen.cs
index 4aca9c60e..79d5ec8ff 100644
--- a/src/core-sdk-tasks/Crossgen.cs
+++ b/src/core-sdk-tasks/Crossgen.cs
@@ -27,7 +27,7 @@ namespace Microsoft.DotNet.Build.Tasks
public string DestinationPath { get; set; }
[Required]
- public string JITPath { get; set; }
+ public string Architecture { get; set; }
public string CrossgenPath { get; set; }
@@ -138,7 +138,12 @@ namespace Microsoft.DotNet.Build.Tasks
protected override string GenerateCommandLineCommands()
{
- return $"{GetInPath()} {GetOutPath()} {GetPlatformAssemblyPaths()} {GetCreateSymbols()}";
+ return $"{GetInPath()} {GetOutPath()} {GetArchitecture()} {GetPlatformAssemblyPaths()} {GetCreateSymbols()}";
+ }
+
+ private string GetArchitecture()
+ {
+ return $"--targetarch {Architecture}";
}
private string GetCreateSymbols()
@@ -192,11 +197,6 @@ namespace Microsoft.DotNet.Build.Tasks
return platformAssemblyPaths;
}
- private string GetJitPath()
- {
- return $"-JITPath {JITPath}";
- }
-
private string GetMissingDependenciesOk()
{
return "-MissingDependenciesOK";
diff --git a/src/redist/targets/Crossgen.targets b/src/redist/targets/Crossgen.targets
index 73a4ebda9..7f64f71e4 100644
--- a/src/redist/targets/Crossgen.targets
+++ b/src/redist/targets/Crossgen.targets
@@ -123,7 +123,7 @@
Date: Fri, 11 Jun 2021 22:10:31 -0700
Subject: [PATCH 3/7] fix naming
Ah case sensitivity.
---
src/redist/targets/Crossgen.targets | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/redist/targets/Crossgen.targets b/src/redist/targets/Crossgen.targets
index 7f64f71e4..0df92aeb5 100644
--- a/src/redist/targets/Crossgen.targets
+++ b/src/redist/targets/Crossgen.targets
@@ -5,7 +5,7 @@
microsoft.netcore.app.runtime.$(SharedFrameworkRid)
- Microsoft.NETCore.App.Crossgen2.$(SharedFrameworkRid)
+ microsoft.netcore.app.crossgen2.$(SharedFrameworkRid)
<_crossDir Condition="'$(Architecture)' == 'arm64' and '$(BuildArchitecture)' != 'arm64'">/x64_arm64
<_crossDir Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'win'">/x86_arm
<_crossDir Condition="'$(Architecture)' == 'arm' And '$(OSName)' != 'win'">/x64_arm
From 38a2c601995c5d4d78de23229c3587c22c77923b Mon Sep 17 00:00:00 2001
From: Manish Godse <61718172+mangod9@users.noreply.github.com>
Date: Fri, 11 Jun 2021 22:54:54 -0700
Subject: [PATCH 4/7] Fix cross builds.
---
src/core-sdk-tasks/Crossgen.cs | 12 ------------
src/redist/targets/Crossgen.targets | 17 +----------------
2 files changed, 1 insertion(+), 28 deletions(-)
diff --git a/src/core-sdk-tasks/Crossgen.cs b/src/core-sdk-tasks/Crossgen.cs
index 79d5ec8ff..2659c26d3 100644
--- a/src/core-sdk-tasks/Crossgen.cs
+++ b/src/core-sdk-tasks/Crossgen.cs
@@ -33,8 +33,6 @@ namespace Microsoft.DotNet.Build.Tasks
public bool CreateSymbols { get; set; }
- public string DiasymReaderPath { get; set; }
-
public bool ReadyToRun { get; set; }
public ITaskItem[] PlatformAssemblyPaths { get; set; }
@@ -152,16 +150,6 @@ namespace Microsoft.DotNet.Build.Tasks
return $"{option}";
}
- private string GetDiasymReaderPath()
- {
- if (string.IsNullOrEmpty(DiasymReaderPath))
- {
- return null;
- }
-
- return $"-diasymreaderpath \"{DiasymReaderPath}\"";
- }
-
private string GetReadyToRun()
{
if (ReadyToRun)
diff --git a/src/redist/targets/Crossgen.targets b/src/redist/targets/Crossgen.targets
index 0df92aeb5..9d67eade9 100644
--- a/src/redist/targets/Crossgen.targets
+++ b/src/redist/targets/Crossgen.targets
@@ -5,20 +5,9 @@
microsoft.netcore.app.runtime.$(SharedFrameworkRid)
- microsoft.netcore.app.crossgen2.$(SharedFrameworkRid)
- <_crossDir Condition="'$(Architecture)' == 'arm64' and '$(BuildArchitecture)' != 'arm64'">/x64_arm64
- <_crossDir Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'win'">/x86_arm
- <_crossDir Condition="'$(Architecture)' == 'arm' And '$(OSName)' != 'win'">/x64_arm
+ microsoft.netcore.app.crossgen2.$(OSName)-$(BuildArchitecture)
$(NuGetPackageRoot)/$(RuntimeNETCrossgenPackageName)/$(MicrosoftNETCoreAppRuntimePackageVersion)/tools/crossgen2$(ExeExtension)
- x64_arm64
- x86_arm
- x64_arm
- $(SharedFrameworkRid)
- $(NuGetPackageRoot)/$(RuntimeNETCoreAppPackageName)/$(MicrosoftNETCoreAppRuntimePackageVersion)/runtimes/$(LibCLRJitRid)/native/$(DynamicLibPrefix)clrjit$(DynamicLibExtension)
$(RedistLayoutPath)shared/$(SharedFrameworkName)/$(MicrosoftNETCoreAppRuntimePackageVersion)
- *
- x86
- amd64
@@ -79,7 +68,6 @@
-
@@ -127,7 +115,6 @@
CrossgenPath="$(CrossgenPath)"
ReadyToRun="True"
CreateSymbols="$(CreateCrossgenSymbols)"
- DiasymReaderPath="@(DiasymReaderPath)"
PlatformAssemblyPaths="@(RoslynFolders);$(SharedFrameworkNameVersionPath)" />
From 1013c2b24dca61026f33e05d6cc6c228ec80b3c4 Mon Sep 17 00:00:00 2001
From: Manish Godse <61718172+mangod9@users.noreply.github.com>
Date: Sat, 12 Jun 2021 01:18:24 -0700
Subject: [PATCH 5/7] fix musl builds
---
src/redist/targets/Crossgen.targets | 2 +-
src/redist/targets/GetRuntimeInformation.targets | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/redist/targets/Crossgen.targets b/src/redist/targets/Crossgen.targets
index 9d67eade9..79d6264bd 100644
--- a/src/redist/targets/Crossgen.targets
+++ b/src/redist/targets/Crossgen.targets
@@ -5,7 +5,7 @@
microsoft.netcore.app.runtime.$(SharedFrameworkRid)
- microsoft.netcore.app.crossgen2.$(OSName)-$(BuildArchitecture)
+ microsoft.netcore.app.crossgen2.$(HostOSName)-$(BuildArchitecture)
$(NuGetPackageRoot)/$(RuntimeNETCrossgenPackageName)/$(MicrosoftNETCoreAppRuntimePackageVersion)/tools/crossgen2$(ExeExtension)
$(RedistLayoutPath)shared/$(SharedFrameworkName)/$(MicrosoftNETCoreAppRuntimePackageVersion)
diff --git a/src/redist/targets/GetRuntimeInformation.targets b/src/redist/targets/GetRuntimeInformation.targets
index 7d75f8f10..bf50bc405 100644
--- a/src/redist/targets/GetRuntimeInformation.targets
+++ b/src/redist/targets/GetRuntimeInformation.targets
@@ -10,6 +10,11 @@
freebsd
linux
+ win
+ osx
+ freebsd
+ linux
+
$(OSName)-$(Architecture)
From bc6490c5981a958323da1d079d86bcc481f91fd3 Mon Sep 17 00:00:00 2001
From: Manish Godse <61718172+mangod9@users.noreply.github.com>
Date: Sat, 12 Jun 2021 01:55:58 -0700
Subject: [PATCH 6/7] fix musl built on alpine
---
.vsts-ci.yml | 6 ++++--
src/core-sdk-tasks/Crossgen.cs | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/.vsts-ci.yml b/.vsts-ci.yml
index 2292860fd..10b172fc5 100644
--- a/.vsts-ci.yml
+++ b/.vsts-ci.yml
@@ -217,7 +217,8 @@ stages:
_LinuxPortable: ''
_RuntimeIdentifier: '--runtime-id linux-musl-x64'
_BuildArchitecture: 'x64'
- _AdditionalBuildParameters: '/p:OSName="linux-musl"'
+ # Pass in HostOSName when running on alpine
+ _AdditionalBuildParameters: '/p:OSName="linux-musl" /p:HostOSName="linux-musl"'
_TestArg: $(_NonWindowsTestArg)
${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
Build_Arm_Release:
@@ -261,7 +262,8 @@ stages:
_LinuxPortable: ''
_RuntimeIdentifier: '--runtime-id linux-musl-x64'
_BuildArchitecture: 'x64'
- _AdditionalBuildParameters: '/p:OSName="linux-musl"'
+ # Pass in HostOSName when running on alpine
+ _AdditionalBuildParameters: '/p:OSName="linux-musl" /p:HostOSName="linux-musl"'
Build_Linux_Portable_Deb_Release_x64:
_BuildConfig: Release
_DockerParameter: '--docker ubuntu.16.04'
diff --git a/src/core-sdk-tasks/Crossgen.cs b/src/core-sdk-tasks/Crossgen.cs
index 2659c26d3..af916b1b9 100644
--- a/src/core-sdk-tasks/Crossgen.cs
+++ b/src/core-sdk-tasks/Crossgen.cs
@@ -68,7 +68,7 @@ namespace Microsoft.DotNet.Build.Tasks
// Copy both dll and pdb files to the destination folder
foreach(var file in files)
{
- File.Copy(file, $"{dest}{Path.GetFileName(file)}", overwrite: true);
+ File.Copy(file, $"{dest}{Path.DirectorySeparatorChar}{Path.GetFileName(file)}", overwrite: true);
// Delete file in temp
File.Delete(file);
}
From 959245b50aba0bc2bd4b05a23e3d4e9374c1eded Mon Sep 17 00:00:00 2001
From: Manish Godse <61718172+mangod9@users.noreply.github.com>
Date: Sun, 13 Jun 2021 17:47:24 -0700
Subject: [PATCH 7/7] CR feedback
---
src/core-sdk-tasks/Crossgen.cs | 4 ++--
src/redist/targets/GetRuntimeInformation.targets | 7 ++-----
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/core-sdk-tasks/Crossgen.cs b/src/core-sdk-tasks/Crossgen.cs
index af916b1b9..a45e3d96f 100644
--- a/src/core-sdk-tasks/Crossgen.cs
+++ b/src/core-sdk-tasks/Crossgen.cs
@@ -68,7 +68,7 @@ namespace Microsoft.DotNet.Build.Tasks
// Copy both dll and pdb files to the destination folder
foreach(var file in files)
{
- File.Copy(file, $"{dest}{Path.DirectorySeparatorChar}{Path.GetFileName(file)}", overwrite: true);
+ File.Copy(file, Path.Combine(dest, Path.GetFileName(file)), overwrite: true);
// Delete file in temp
File.Delete(file);
}
@@ -162,7 +162,7 @@ namespace Microsoft.DotNet.Build.Tasks
private string GetInPath()
{
- return $" \"{SourceAssembly}\"";
+ return $"\"{SourceAssembly}\"";
}
private string GetOutPath()
diff --git a/src/redist/targets/GetRuntimeInformation.targets b/src/redist/targets/GetRuntimeInformation.targets
index bf50bc405..549b8e48b 100644
--- a/src/redist/targets/GetRuntimeInformation.targets
+++ b/src/redist/targets/GetRuntimeInformation.targets
@@ -5,15 +5,12 @@
win-$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant)
True
- win
- osx
- freebsd
- linux
-
win
osx
freebsd
linux
+
+ $(HostOSName)
$(OSName)-$(Architecture)