Merge pull request #2991 from livarcocc/enable_msbuild_extensions

Re-enable the generation of the msbuildextensions nupkg.
This commit is contained in:
Livar 2019-07-12 16:28:53 -07:00 committed by GitHub
commit c2d83f9431
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 146 additions and 11 deletions

View file

@ -16,8 +16,7 @@
<CoreSdkTargetFramework>netcoreapp3.0</CoreSdkTargetFramework>
<ArtifactsShippingSymbolsDir>$(ArtifactsDir)symbols\$(Configuration)\Shipping</ArtifactsShippingSymbolsDir>
<NoWarn>NU5125;NU5105</NoWarn>
<NoWarn>NU5125;NU5105;NU1701</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(DisableSourceLink)' == 'true'">

View file

@ -45,6 +45,7 @@
<PropertyGroup>
<!-- Dependencies from https://github.com/dotnet/sdk (to run tests) -->
<MicrosoftNETSdkPackageVersion>3.0.100-preview8.19362.4</MicrosoftNETSdkPackageVersion>
<MicrosoftNETBuildExtensionsPackageVersion>$(MicrosoftNETSdkPackageVersion)</MicrosoftNETBuildExtensionsPackageVersion>
</PropertyGroup>
<PropertyGroup>
<MicrosoftNETCoreAppPackageVersion>3.0.0-preview8-27912-07</MicrosoftNETCoreAppPackageVersion>
@ -70,6 +71,10 @@
<MicrosoftNETTestSdkVersion>15.8.0</MicrosoftNETTestSdkVersion>
<MicrosoftSourceLinkVersion>1.0.0-beta2-18618-05</MicrosoftSourceLinkVersion>
</PropertyGroup>
<PropertyGroup>
<!-- pinned dependency. This package is not being produced outside of the 2.0 branch of corefx and should not change. -->
<CLI_NETStandardLibraryNETFrameworkVersion>2.0.1-servicing-26011-01</CLI_NETStandardLibraryNETFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<RestoreSources>
$(RestoreSources);

View file

@ -0,0 +1,83 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using System;
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)
";
}
}

View file

@ -30,6 +30,7 @@
<Import Project="targets\GenerateBundledVersions.targets" />
<Import Project="targets\Crossgen.targets" />
<Import Project="targets\GenerateLayout.targets" />
<Import Project="targets\GenerateMSBuildExtensions.targets" />
<Import Project="targets\FileExtensions.targets" />
<Import Project="targets\GenerateArchives.targets" />

View file

@ -37,5 +37,6 @@
<UsingTask TaskName="CopyBlobsToLatest" AssemblyFile="$(CoreSdkTaskDll)"/>
<UsingTask TaskName="GenerateChecksums" AssemblyFile="$(CoreSdkTaskDll)"/>
<UsingTask TaskName="GetRuntimePackRids" AssemblyFile="$(CoreSdkTaskDll)"/>
<UsingTask TaskName="GenerateMSBuildExtensionsSWR" AssemblyFile="$(CoreSdkTaskDll)"/>
</Project>

View file

@ -0,0 +1,49 @@
<Project>
<PropertyGroup>
<MSBuildExtensionsLayoutDirectory>$(BaseOutputPath)$(Configuration)\MSBuildExtensionsLayout\</MSBuildExtensionsLayoutDirectory>
<MSBuildExtensionsPackageName>Microsoft.NET.Build.Extensions</MSBuildExtensionsPackageName>
<MSBuildExtensionsNuPkgPath>$(NuGetPackageRoot)$(MSBuildExtensionsPackageName.ToLower())/$(MicrosoftNETBuildExtensionsPackageVersion.ToLower())</MSBuildExtensionsNuPkgPath>
<NETStandardLibraryNETFrameworkPackageName>NETStandard.Library.NETFramework</NETStandardLibraryNETFrameworkPackageName>
<NETStandardLibraryNETFrameworkNuPkgPath>$(NuGetPackageRoot)$(NETStandardLibraryNETFrameworkPackageName.ToLower())/$(CLI_NETStandardLibraryNETFrameworkVersion.ToLower())</NETStandardLibraryNETFrameworkNuPkgPath>
</PropertyGroup>
<ItemGroup>
<ExtensionPackageToRestore Include="$(MSBuildExtensionsPackageName)" Version="$(MicrosoftNETBuildExtensionsPackageVersion)"/>
<ExtensionPackageToRestore Include="$(NETStandardLibraryNETFrameworkPackageName)" Version="$(CLI_NETStandardLibraryNETFrameworkVersion)"/>
</ItemGroup>
<!-- Restore msbuild extensions via PackageReference -->
<ItemGroup>
<PackageReference Include="@(ExtensionPackageToRestore)" />
</ItemGroup>
<Target Name="GenerateMSBuildExtensions" DependsOnTargets="GenerateBundledVersionsProps">
<ItemGroup>
<!-- 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\Microsoft.NET.Build.Extensions\net*\**"
DeploymentSubpath="msbuildExtensions/"/>
<!-- Don't include .NET Core MS.NET.Build.Extensions tasks in Full Framework MSBuild layout -->
<VSMSBuildExtensionsContent Remove="$(MSBuildExtensionsNuPkgPath)\msbuildExtensions\Microsoft\Microsoft.NET.Build.Extensions\tools\netcoreapp*\**" />
<VSMSBuildExtensionsContent Include="$(MSBuildExtensionsNuPkgPath)\msbuildExtensions-ver\**\*.*"
DeploymentSubpath="msbuildExtensions-ver/"/>
<VSMSBuildExtensionsContent Include="$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.*"
Exclude="$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.props;$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.targets"
DeploymentSubpath="msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/" />
<VSMSBuildExtensionsContent Include="$(SdkResolverLayoutPath)/**/*"
DeploymentSubpath="MSBuildSdkResolver/" />
<VSMSBuildExtensionsContent Update="@(VSMSBuildExtensionsContent)">
<DestinationPath >$(MSBuildExtensionsLayoutDirectory)/%(VSMSBuildExtensionsContent.DeploymentSubpath)%(RecursiveDir)%(Filename)%(Extension)</DestinationPath>
</VSMSBuildExtensionsContent>
</ItemGroup>
<Copy SourceFiles="@(VSMSBuildExtensionsContent)" DestinationFiles="%(VSMSBuildExtensionsContent.DestinationPath)" />
</Target>
</Project>

View file

@ -28,9 +28,9 @@
<VSToolsResolverNuspecFile>$(MSBuildThisFileDirectory)packaging/windows/clisdk/VS.Tools.Net.Core.SDK.Resolver.nuspec</VSToolsResolverNuspecFile>
<VSToolsResolverNupkgFile>$(ArtifactsNonShippingPackagesDir)VS.Tools.Net.Core.SDK.Resolver.nupkg</VSToolsResolverNupkgFile>
<!--<SdkMSBuildExtensionsNuspecFile>$(MSBuildThisFileDirectory)packaging/windows/clisdk/VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.nuspec</SdkMSBuildExtensionsNuspecFile>
<SdkMSBuildExtensionsNuspecFile>$(MSBuildThisFileDirectory)packaging/windows/clisdk/VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.nuspec</SdkMSBuildExtensionsNuspecFile>
<SdkMSBuildExtensionsNupkgFile>$(ArtifactsNonShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.$(FullNugetVersion).nupkg</SdkMSBuildExtensionsNupkgFile>
<SdkMSBuildExtensionsSwrFile>$(ArtifactsNonShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.swr</SdkMSBuildExtensionsSwrFile>-->
<SdkMSBuildExtensionsSwrFile>$(ArtifactsNonShippingPackagesDir)VS.Redist.Common.Net.Core.SDK.MSBuildExtensions.swr</SdkMSBuildExtensionsSwrFile>
</PropertyGroup>
<PropertyGroup>
@ -208,24 +208,21 @@
</Target>
<Target Name="GenerateSdkMSBuildExtensionsNupkg"
DependsOnTargets="GenerateLayout;MsiTargetsSetupInputOutputs"
DependsOnTargets="GenerateLayout;GenerateMSBuildExtensions;MsiTargetsSetupInputOutputs"
Condition=" '$(OS)' == 'Windows_NT' And '$(Architecture)' == 'x64' "
Inputs="$(MSBuildExtensionsLayoutDirectory)/**/*;
$(SdkMSBuildExtensionsNuspecFile);
$(GenerateNupkgPowershellScript)"
Outputs="$(SdkMSBuildExtensionsNupkgFile);$(SdkMSBuildExtensionsSwrFile)">
<!-- Disabling this for now because we don't have the MSBuildExtensions available.
https://github.com/dotnet/cli/issues/10260 -->
<!-- <Exec Command="powershell -NoProfile -NoLogo -InformationAction Continue $(GenerateNupkgPowershellScript) ^
'$(MSBuildExtensionsLayoutDirectory)' ^
<Exec Command="powershell -NoProfile -NoLogo $(GenerateNupkgPowershellScript) ^
'$(MSBuildExtensionsLayoutDirectory.TrimEnd('\'))' ^
'$(FullNugetVersion)' ^
'$(SdkMSBuildExtensionsNuspecFile)' ^
'$(SdkMSBuildExtensionsNupkgFile)'" />
<GenerateMSBuildExtensionsSWR MSBuildExtensionsLayoutDirectory="$(MSBuildExtensionsLayoutDirectory)"
OutputFile="$(SdkMSBuildExtensionsSwrFile)"/> -->
OutputFile="$(SdkMSBuildExtensionsSwrFile)"/>
</Target>