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

Add NuGetSdkResolver to minimal msbuild #1696

Merged
merged 4 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
<add key="OmniSharp" value="https://www.myget.org/F/omnisharp/api/v3/index.json" />
<add key="roslyn-myget" value="https://dotnet.myget.org/F/roslyn/api/v3/index.json" />
<add key="nuget-build" value="https://dotnet.myget.org/F/nuget-build/api/v3/index.json" />
<add key="vs-editor" value="https://myget.org/F/vs-editor/api/v3/index.json" />
</packageSources>
</configuration>
45 changes: 35 additions & 10 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -265,27 +265,43 @@ Task("CreateMSBuildFolder")

// Copy MSBuild SDK Resolver and DotNetHostResolver
Information("Copying MSBuild SDK resolver...");
var sdkResolverSourceFolder = CombinePaths(env.Folders.Tools, "Microsoft.DotNet.MSBuildSdkResolver", "lib", sdkResolverTFM);
var sdkResolverTargetFolder = CombinePaths(msbuildCurrentBinTargetFolder, "SdkResolvers", "Microsoft.DotNet.MSBuildSdkResolver");
DirectoryHelper.ForceCreate(sdkResolverTargetFolder);
var msbuildSdkResolverSourceFolder = CombinePaths(env.Folders.Tools, "Microsoft.DotNet.MSBuildSdkResolver", "lib", sdkResolverTFM);
var msbuildSdkResolverTargetFolder = CombinePaths(msbuildCurrentBinTargetFolder, "SdkResolvers", "Microsoft.DotNet.MSBuildSdkResolver");
DirectoryHelper.ForceCreate(msbuildSdkResolverTargetFolder);
FileHelper.Copy(
source: CombinePaths(sdkResolverSourceFolder, "Microsoft.DotNet.MSBuildSdkResolver.dll"),
destination: CombinePaths(sdkResolverTargetFolder, "Microsoft.DotNet.MSBuildSdkResolver.dll"));
source: CombinePaths(msbuildSdkResolverSourceFolder, "Microsoft.DotNet.MSBuildSdkResolver.dll"),
destination: CombinePaths(msbuildSdkResolverTargetFolder, "Microsoft.DotNet.MSBuildSdkResolver.dll"));

if (Platform.Current.IsWindows)
{
CopyDotNetHostResolver(env, "win", "x86", "hostfxr.dll", sdkResolverTargetFolder, copyToArchSpecificFolder: true);
CopyDotNetHostResolver(env, "win", "x64", "hostfxr.dll", sdkResolverTargetFolder, copyToArchSpecificFolder: true);
CopyDotNetHostResolver(env, "win", "x86", "hostfxr.dll", msbuildSdkResolverTargetFolder, copyToArchSpecificFolder: true);
CopyDotNetHostResolver(env, "win", "x64", "hostfxr.dll", msbuildSdkResolverTargetFolder, copyToArchSpecificFolder: true);
}
else if (Platform.Current.IsMacOS)
{
CopyDotNetHostResolver(env, "osx", "x64", "libhostfxr.dylib", sdkResolverTargetFolder, copyToArchSpecificFolder: false);
CopyDotNetHostResolver(env, "osx", "x64", "libhostfxr.dylib", msbuildSdkResolverTargetFolder, copyToArchSpecificFolder: false);
}
else if (Platform.Current.IsLinux)
{
CopyDotNetHostResolver(env, "linux", "x64", "libhostfxr.so", sdkResolverTargetFolder, copyToArchSpecificFolder: false);
CopyDotNetHostResolver(env, "linux", "x64", "libhostfxr.so", msbuildSdkResolverTargetFolder, copyToArchSpecificFolder: false);
}

Information("Copying NuGet SDK resolver...");
var nugetSdkResolverSourceFolder = CombinePaths(env.Folders.Tools, "Microsoft.Build.NuGetSdkResolver", "lib", sdkResolverTFM);
var nugetSdkResolverTargetFolder = CombinePaths(msbuildCurrentBinTargetFolder, "SdkResolvers", "Microsoft.Build.NuGetSdkResolver");
DirectoryHelper.ForceCreate(nugetSdkResolverTargetFolder);
FileHelper.Copy(
source: CombinePaths(nugetSdkResolverSourceFolder, "Microsoft.Build.NuGetSdkResolver.dll"),
destination: CombinePaths(msbuildCurrentBinTargetFolder, "Microsoft.Build.NuGetSdkResolver.dll"));
FileHelper.WriteAllLines(
path: CombinePaths(nugetSdkResolverTargetFolder, "Microsoft.Build.NuGetSdkResolver.xml"),
contents: new [] {
"<SdkResolver>",
" <Path>../../Microsoft.Build.NuGetSdkResolver.dll</Path>",
"</SdkResolver>"
}
);

// Copy content of NuGet.Build.Tasks
var nugetBuildTasksFolder = CombinePaths(env.Folders.Tools, "NuGet.Build.Tasks");
var nugetBuildTasksBinariesFolder = CombinePaths(nugetBuildTasksFolder, "lib", "net472");
Expand All @@ -299,13 +315,17 @@ Task("CreateMSBuildFolder")
source: CombinePaths(nugetBuildTasksTargetsFolder, "NuGet.targets"),
destination: CombinePaths(msbuildCurrentBinTargetFolder, "NuGet.targets"));

// Copy dependencies of NuGet.Build.Tasks
// Copy dependencies of NuGet.Build.Tasks & Microsoft.Build.NuGetSdkResolver
var nugetPackages = new []
{
"NuGet.Commands",
"NuGet.Common",
"NuGet.Configuration",
"NuGet.Credentials",
"NuGet.DependencyResolver.Core",
"NuGet.Frameworks",
"NuGet.LibraryModel",
"NuGet.Packaging",
"NuGet.ProjectModel",
"NuGet.Protocol",
"NuGet.Versioning"
Expand All @@ -320,6 +340,11 @@ Task("CreateMSBuildFolder")
destination: CombinePaths(msbuildCurrentBinTargetFolder, binaryName));
}

// Copy additional dependency of Microsoft.Build.NuGetSdkResolver
FileHelper.Copy(
source: CombinePaths(env.Folders.Tools, "Newtonsoft.Json", "lib", "net45", "Newtonsoft.Json.dll"),
destination: CombinePaths(msbuildCurrentBinTargetFolder, "Newtonsoft.Json.dll"));

// Copy content of Microsoft.Net.Compilers
Information("Copying Microsoft.Net.Compilers...");
var compilersSourceFolder = CombinePaths(env.Folders.Tools, "Microsoft.Net.Compilers", "tools");
Expand Down
22 changes: 14 additions & 8 deletions tools/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@
<package id="Microsoft.Build.Utilities.Core" version="16.4.0" />
<package id="Microsoft.Net.Compilers" version="3.4.0" />
<package id="Microsoft.DotNet.MSBuildSdkResolver" version="3.0.101-servicing.19476.7" />
<package id="NuGet.Build.Tasks" version="5.3.1" />
<package id="NuGet.Commands" version="5.3.1" />
<package id="NuGet.Common" version="5.3.1" />
<package id="NuGet.Configuration" version="5.3.1" />
<package id="NuGet.Frameworks" version="5.3.1" />
<package id="NuGet.ProjectModel" version="5.3.1" />
<package id="NuGet.Protocol" version="5.3.1" />
<package id="NuGet.Versioning" version="5.3.1" />
<package id="Microsoft.Build.NuGetSdkResolver" version="5.4.0-rtm.6292" />
<package id="Newtonsoft.Json" version="9.0.1" />
<package id="NuGet.Build.Tasks" version="5.4.0-rtm.6292" />
<package id="NuGet.Commands" version="5.4.0-rtm.6292" />
<package id="NuGet.Common" version="5.4.0-rtm.6292" />
<package id="NuGet.Configuration" version="5.4.0-rtm.6292" />
<package id="NuGet.Credentials" version="5.4.0-rtm.6292" />
<package id="NuGet.DependencyResolver.Core" version="5.4.0-rtm.6292" />
<package id="NuGet.Frameworks" version="5.4.0-rtm.6292" />
<package id="NuGet.LibraryModel" version="5.4.0-rtm.6292" />
<package id="NuGet.Packaging" version="5.4.0-rtm.6292" />
<package id="NuGet.ProjectModel" version="5.4.0-rtm.6292" />
<package id="NuGet.Protocol" version="5.4.0-rtm.6292" />
<package id="NuGet.Versioning" version="5.4.0-rtm.6292" />
<package id="runtime.linux-x64.Microsoft.NETCore.DotNetHostResolver" version="3.0.0" />
<package id="runtime.osx-x64.Microsoft.NETCore.DotNetHostResolver" version="3.0.0" />
<package id="runtime.win-x64.Microsoft.NETCore.DotNetHostResolver" version="3.0.0" />
Expand Down