Add Microsoft.NET.Build.Extensions files to package for VS insertion

This commit is contained in:
Daniel Plaisted 2017-06-09 11:18:46 -07:00
parent 6b44f8938b
commit 9cd4e5a956
5 changed files with 112 additions and 4 deletions

View file

@ -3,6 +3,8 @@
DependsOnTargets="GenerateBundledVersionsProps;RestoreMSBuildExtensionsPackages">
<ItemGroup>
<!-- The MSBuildExtensionsContent item is for the files that will be laid out in the CLI install -->
<MSBuildExtensionsContent Include="$(GeneratedMSBuildExtensionsDirectory)/**/*" />
<!-- We want to include the tasks and targets from the Microsoft.NET.Build.Extensions package, but we don't want to include the DLLs
@ -22,7 +24,25 @@
<MSBuildExtensionsContent Include="$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.*"
Exclude="$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.props;$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.targets"
DeploymentSubpath="Microsoft.NET.Build.Extensions/" />
<!-- The VSMSBuildExtensionsContent item is for the files that will be included in the VS.Redist.Common.Net.Core.SDK.MSBuildExtensions
package and inserted into Visual Studio -->
<VSMSBuildExtensionsContent Include="$(MSBuildExtensionsNuPkgPath)\msbuildExtensions\**\*.*"
Exclude="$(MSBuildExtensionsNuPkgPath)\msbuildExtensions\Microsoft.NET.Build.Extensions\net*\**"
DeploymentSubpath="msbuildExtensions/"/>
<VSMSBuildExtensionsContent Include="$(MSBuildExtensionsNuPkgPath)\msbuildExtensions-ver\**\*.*"
DeploymentSubpath="msbuildExtensions-ver/"/>
<VSMSBuildExtensionsContent Include="$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.*"
Exclude="$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.props;$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.targets"
DeploymentSubpath="msbuildExtensions/Microsoft.NET.Build.Extensions/" />
<VSMSBuildExtensionsContent Update="@(VSMSBuildExtensionsContent)">
<DestinationPath >$(MSBuildExtensionsLayoutDirectory)/%(VSMSBuildExtensionsContent.DeploymentSubpath)%(RecursiveDir)%(Filename)%(Extension)</DestinationPath>
</VSMSBuildExtensionsContent>
</ItemGroup>
<Copy SourceFiles="@(VSMSBuildExtensionsContent)" DestinationFiles="%(VSMSBuildExtensionsContent.DestinationPath)" />
</Target>
<Target Name="PrepareMSBuildExtensionsProps">

View file

@ -19,6 +19,7 @@
<UsingTask TaskName="DownloadFile" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="GenerateChecksums" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="GenerateGuidFromName" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="GenerateMSBuildExtensionsSWR" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="GenerateMsiVersion" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="GenerateNuGetPackagesArchiveVersion" AssemblyFile="$(CLIBuildDll)" />
<UsingTask TaskName="GetCurrentRuntimeInformation" AssemblyFile="$(CLIBuildDll)" />

View file

@ -17,6 +17,7 @@
<TestOutputDir>$(RepoRoot)/artifacts/testpackages/</TestOutputDir>
<DotnetInOutputDirectory>$(OutputDirectory)/dotnet$(ExeExtension)</DotnetInOutputDirectory>
<GeneratedMSBuildExtensionsDirectory>$(IntermediateDirectory)/GeneratedMSBuildExtensions</GeneratedMSBuildExtensionsDirectory>
<SdkResolverOutputDirectory>$(IntermediateDirectory)/MSBuildSdkResolver</SdkResolverOutputDirectory>
<MSBuildExtensionsLayoutDirectory>$(IntermediateDirectory)/MSBuildExtensionsLayout</MSBuildExtensionsLayoutDirectory>
<SdkResolverOutputDirectory>$(MSBuildExtensionsLayoutDirectory)/MSBuildSdkResolver</SdkResolverOutputDirectory>
</PropertyGroup>
</Project>

View file

@ -22,6 +22,7 @@
<SdkMSBuildExtensionsNuspecFile>$(RepoRoot)/packaging/windows/clisdk/VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.nuspec</SdkMSBuildExtensionsNuspecFile>
<SdkMSBuildExtensionsNupkgFile>$(InstallerOutputDirectory)/VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.$(FullNugetVersion).nupkg</SdkMSBuildExtensionsNupkgFile>
<SdkMSBuildExtensionsSwrFile>$(InstallerOutputDirectory)/VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.swr</SdkMSBuildExtensionsSwrFile>
</PropertyGroup>
<!-- Test Sdk MSI Properties -->
@ -146,16 +147,20 @@
<Target Name="GenerateSdkMSBuildExtensionsNupkg"
DependsOnTargets="Init;Layout;MsiTargetsSetupInputOutputs;GenerateSdkBundle"
Condition=" '$(OS)' == 'Windows_NT'"
Inputs="$(SdkResolverOutputDirectory)/**/*;
Inputs="$(MSBuildExtensionsLayoutDirectory)/**/*;
$(SdkInstallerNuspecFile);
$(SdkGenerateNupkgPowershellScript)"
Outputs="$(SdkInstallerNupkgFile)">
Outputs="$(SdkMSBuildExtensionsNupkgFile);$(SdkMSBuildExtensionsSwrFile)">
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateNupkgPowershellScript)
'$(SdkResolverOutputDirectory)'
'$(MSBuildExtensionsLayoutDirectory)'
'$(FullNugetVersion)'
'$(SdkMSBuildExtensionsNuspecFile)'
'$(SdkMSBuildExtensionsNupkgFile)'" />
<GenerateMSBuildExtensionsSWR MSBuildExtensionsLayoutDirectory="$(MSBuildExtensionsLayoutDirectory)"
OutputFile="$(SdkMSBuildExtensionsSwrFile)"/>
</Target>
<Target Name="TestSdkMsi"

View file

@ -0,0 +1,81 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Microsoft.DotNet.Cli.Build
{
public class GenerateMSBuildExtensionsSWR : Task
{
[Required]
public string MSBuildExtensionsLayoutDirectory { get; set; }
[Required]
public string OutputFile { get; set; }
public override bool Execute()
{
StringBuilder sb = new StringBuilder(SWR_HEADER);
AddFolder(sb,
@"MSBuildSdkResolver",
@"MSBuild\15.0\Bin\SdkResolvers\Microsoft.DotNet.MSBuildSdkResolver");
AddFolder(sb,
@"msbuildExtensions",
@"MSBuild");
AddFolder(sb,
@"msbuildExtensions-ver",
@"MSBuild\15.0");
File.WriteAllText(OutputFile, sb.ToString());
return true;
}
private void AddFolder(StringBuilder sb, string relativeSourcePath, string swrInstallDir)
{
string sourceFolder = Path.Combine(MSBuildExtensionsLayoutDirectory, relativeSourcePath);
var files = Directory.GetFiles(sourceFolder)
.Where(f => !Path.GetExtension(f).Equals(".pdb", StringComparison.OrdinalIgnoreCase))
.ToList();
if (files.Any())
{
sb.Append(@"folder ""InstallDir:\");
sb.Append(swrInstallDir);
sb.AppendLine(@"\""");
foreach (var file in files)
{
sb.Append(@" file source=""!(bindpath.sources)\Redist\Common\NetCoreSDK\MSBuildExtensions\");
sb.Append(Path.Combine(relativeSourcePath, Path.GetFileName(file)));
sb.AppendLine("\"");
}
sb.AppendLine();
}
foreach (var subfolder in Directory.GetDirectories(sourceFolder))
{
string subfolderName = Path.GetFileName(subfolder);
string newRelativeSourcePath = Path.Combine(relativeSourcePath, subfolderName);
string newSwrInstallDir = Path.Combine(swrInstallDir, subfolderName);
AddFolder(sb, newRelativeSourcePath, newSwrInstallDir);
}
}
readonly string SWR_HEADER = @"use vs
package name=Microsoft.Net.Core.SDK.MSBuildExtensions
version=$(Version)
vs.package.branch=$(VsSingletonPackageBranch)
vs.package.internalRevision=$(PackageInternalRevision)
";
}
}