Skip to content
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

NGEN Microsoft.DotNet.MSBuildSdkResolver.dll and its dependencies #17732

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/core-sdk-tasks/GenerateMSBuildExtensionsSWR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,25 @@ public override bool Execute()

AddFolder(sb,
@"MSBuildSdkResolver",
@"MSBuild\Current\Bin\SdkResolvers\Microsoft.DotNet.MSBuildSdkResolver");
@"MSBuild\Current\Bin\SdkResolvers\Microsoft.DotNet.MSBuildSdkResolver",
ngenAssemblies: true);

AddFolder(sb,
@"msbuildExtensions",
@"MSBuild");
@"MSBuild",
ngenAssemblies: false);

AddFolder(sb,
@"msbuildExtensions-ver",
@"MSBuild\Current");
@"MSBuild\Current",
ngenAssemblies: false);

File.WriteAllText(OutputFile, sb.ToString());

return true;
}

private void AddFolder(StringBuilder sb, string relativeSourcePath, string swrInstallDir)
private void AddFolder(StringBuilder sb, string relativeSourcePath, string swrInstallDir, bool ngenAssemblies)
ladipro marked this conversation as resolved.
Show resolved Hide resolved
{
string sourceFolder = Path.Combine(MSBuildExtensionsLayoutDirectory, relativeSourcePath);
var files = Directory.GetFiles(sourceFolder)
Expand All @@ -55,7 +58,16 @@ private void AddFolder(StringBuilder sb, string relativeSourcePath, string swrIn
{
sb.Append(@" file source=""$(PkgVS_Redist_Common_Net_Core_SDK_MSBuildExtensions)\");
sb.Append(Path.Combine(relativeSourcePath, Path.GetFileName(file)));
sb.AppendLine("\"");
sb.Append('"');
joeloff marked this conversation as resolved.
Show resolved Hide resolved

if (ngenAssemblies && file.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
{
sb.Append(@" vs.file.ngenApplications=""[installDir]\Common7\IDE\vsn.exe""");
sb.Append(@" vs.file.ngenApplications=""[installDir]\MSBuild\Current\Bin\MSBuild.exe""");
sb.Append(" vs.file.ngenArchitecture=all");
}

sb.AppendLine();
}

sb.AppendLine();
Expand All @@ -67,7 +79,8 @@ private void AddFolder(StringBuilder sb, string relativeSourcePath, string swrIn
string newRelativeSourcePath = Path.Combine(relativeSourcePath, subfolderName);
string newSwrInstallDir = Path.Combine(swrInstallDir, subfolderName);

AddFolder(sb, newRelativeSourcePath, newSwrInstallDir);
// Don't propagate ngenAssemblies to subdirectories.
AddFolder(sb, newRelativeSourcePath, newSwrInstallDir, ngenAssemblies: false);
}
}

Expand Down