Merge pull request #6794 from dsplaisted/6737-Include-Build-Extensions
Add Microsoft.NET.Build.Extensions and corresponding DLLs in CLI layout
This commit is contained in:
commit
07b93e9d7c
12 changed files with 219 additions and 54 deletions
|
@ -1,6 +1,6 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26419.0
|
||||
VisualStudioVersion = 15.0.26510.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED2FE3E2-F7E7-4389-8231-B65123F2076F}"
|
||||
EndProject
|
||||
|
@ -30,7 +30,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{89905EC4
|
|||
build\BuildDefaults.props = build\BuildDefaults.props
|
||||
build\BuildInfo.targets = build\BuildInfo.targets
|
||||
build\BundledRuntimes.props = build\BundledRuntimes.props
|
||||
build\BundledSdks.proj = build\BundledSdks.proj
|
||||
build\BundledSdks.props = build\BundledSdks.props
|
||||
build\BundledTemplates.proj = build\BundledTemplates.proj
|
||||
build\BundledTemplates.props = build\BundledTemplates.props
|
||||
|
@ -48,10 +47,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{89905EC4
|
|||
build\InstallerInfo.props = build\InstallerInfo.props
|
||||
build\Microsoft.DotNet.Cli.tasks = build\Microsoft.DotNet.Cli.tasks
|
||||
build\MSBuildExtensions.props = build\MSBuildExtensions.props
|
||||
build\MSBuildExtensions.targets = build\MSBuildExtensions.targets
|
||||
build\OutputDirectories.props = build\OutputDirectories.props
|
||||
build\Package.targets = build\Package.targets
|
||||
build\Prepare.targets = build\Prepare.targets
|
||||
build\Publish.targets = build\Publish.targets
|
||||
build\RestoreDependency.proj = build\RestoreDependency.proj
|
||||
build\sdks\sdks.csproj = build\sdks\sdks.csproj
|
||||
build\Signing.proj = build\Signing.proj
|
||||
build\Stage0.props = build\Stage0.props
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// 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 System;
|
||||
|
||||
namespace TestApp
|
||||
{
|
||||
class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(TestLibrary.Helper.GetMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TestLibrary\TestLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,24 @@
|
|||
// 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 System;
|
||||
|
||||
namespace TestLibrary
|
||||
{
|
||||
public static class Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the message from the helper. This comment is here to help test XML documentation file generation, please do not remove it.
|
||||
/// </summary>
|
||||
/// <returns>A message</returns>
|
||||
public static string GetMessage()
|
||||
{
|
||||
return "This string came from the test library!";
|
||||
}
|
||||
|
||||
public static void SayHi()
|
||||
{
|
||||
Console.WriteLine("Hello there!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -1,45 +0,0 @@
|
|||
<Project ToolsVersion="15.0" DefaultTargets="CopySdkToOutput">
|
||||
<!-- workaround for https://github.com/Microsoft/msbuild/issues/885 -->
|
||||
<!-- renaming the property because the original property is a global property and therefore
|
||||
cannot be redefined at runtime. -->
|
||||
<PropertyGroup>
|
||||
<CLIBuildDllPath>$([MSBuild]::Unescape($(CLIBuildDll)))</CLIBuildDllPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<UsingTask TaskName="DotNetRestore" AssemblyFile="$(CLIBuildDllPath)" />
|
||||
|
||||
<Target Name="CopySdkToOutput"
|
||||
DependsOnTargets="PrepareBundledSdksProps;
|
||||
EnsureSdkRestored;
|
||||
GetSdkItemsToCopy"
|
||||
Inputs="@(SdkContent)"
|
||||
Outputs="@(SdkContent->'$(SdkLayoutDirectory)/%(RecursiveDir)%(FileName)%(Extension)')">
|
||||
<Copy SourceFiles="@(SdkContent)"
|
||||
DestinationFiles="@(SdkContent->'$(SdkLayoutDirectory)/%(RecursiveDir)%(FileName)%(Extension)')" />
|
||||
|
||||
<Message Text="Copied Sdk $(SdkPackageName) from $(SdkNuPkgPath) to $(SdkLayoutDirectory)."
|
||||
Importance="High" />
|
||||
</Target>
|
||||
|
||||
<Target Name="GetSdkItemsToCopy">
|
||||
<ItemGroup>
|
||||
<SdkContent Include="$(SdkNuPkgPath)/**/*"
|
||||
Exclude="$(SdkNuPkgPath)/$(SdkPackageName).nuspec;
|
||||
$(SdkNuPkgPath)/$(SdkPackageName).$(SdkPackageVersion).nupkg;
|
||||
$(SdkNuPkgPath)/$(SdkPackageName).$(SdkPackageVersion).nupkg.sha512" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="EnsureSdkRestored"
|
||||
Condition="!Exists('$(SdkNuPkgPath)/$(SdkPackageName.ToLower()).nuspec')">
|
||||
<DotNetRestore ToolPath="$(Stage0Directory)"
|
||||
ProjectPath="$(MSBuildThisFileDirectory)/sdks/sdks.csproj"
|
||||
AdditionalParameters="/p:SdkPackageName=$(SdkPackageName) /p:SdkPackageVersion=$(SdkPackageVersion)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="PrepareBundledSdksProps">
|
||||
<PropertyGroup>
|
||||
<SdkNuPkgPath>$(NuGetPackagesDir)/$(SdkPackageName.ToLower())/$(SdkPackageVersion.ToLower())</SdkNuPkgPath>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
</Project>
|
|
@ -6,8 +6,10 @@
|
|||
<CLI_Roslyn_Version>2.3.0-beta2-61716-09</CLI_Roslyn_Version>
|
||||
<CLI_DiaSymNative_Version>1.6.0-beta2-25304</CLI_DiaSymNative_Version>
|
||||
<CLI_FSharp_Version>4.2.0-rc-170602-0</CLI_FSharp_Version>
|
||||
<CLI_NETSDK_Version>2.0.0-preview2-20170608-1</CLI_NETSDK_Version>
|
||||
<CLI_NETSDK_Version>2.0.0-preview2-20170608-2</CLI_NETSDK_Version>
|
||||
<CLI_NuGet_Version>4.3.0-preview3-4146</CLI_NuGet_Version>
|
||||
<CLI_MSBuildExtensions_Version>2.0.0-preview2-20170608-2</CLI_MSBuildExtensions_Version>
|
||||
<CLI_NETStandardLibraryNETFrameworkVersion>2.0.0-preview2-25331-02</CLI_NETStandardLibraryNETFrameworkVersion>
|
||||
<CLI_WEBSDK_Version>2.0.0-rel-20170518-512</CLI_WEBSDK_Version>
|
||||
<CLI_TestPlatform_Version>15.3.0-preview-20170609-02</CLI_TestPlatform_Version>
|
||||
<SharedFrameworkVersion>$(CLI_SharedFrameworkVersion)</SharedFrameworkVersion>
|
||||
|
|
|
@ -1,12 +1,64 @@
|
|||
<Project>
|
||||
<Target Name="GenerateMSBuildExtensions"
|
||||
DependsOnTargets="GenerateBundledVersionsProps">
|
||||
DependsOnTargets="GenerateBundledVersionsProps;RestoreMSBuildExtensionsPackages">
|
||||
|
||||
<ItemGroup>
|
||||
<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
|
||||
from that package under the net461, net462, etc folders. That is because they come from the NETStandard.Library.NETFramework
|
||||
package, and we want to insert them directly into the CLI from CoreFx instead of having to do a two-hop insertion (CoreFX -> SDK -> CLI)
|
||||
if we need to update them.
|
||||
|
||||
https://github.com/dotnet/sdk/issues/1324 has been filed to exclude these from the Microsoft.NET.Build.Extensions package when
|
||||
we generate it.
|
||||
-->
|
||||
<MSBuildExtensionsContent Include="$(MSBuildExtensionsNuPkgPath)\msbuildExtensions\**\*.*"
|
||||
Exclude="$(MSBuildExtensionsNuPkgPath)\msbuildExtensions\Microsoft.NET.Build.Extensions\net*\**" />
|
||||
|
||||
<MSBuildExtensionsContent Include="$(MSBuildExtensionsNuPkgPath)\msbuildExtensions-ver\**\*.*"
|
||||
DeploymentSubpath="$(MSBuildExtensionsVersionSubfolder)/" />
|
||||
|
||||
<MSBuildExtensionsContent Include="$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.*"
|
||||
Exclude="$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.props;$(NETStandardLibraryNETFrameworkNuPkgPath)\build\**\*.targets"
|
||||
DeploymentSubpath="Microsoft.NET.Build.Extensions/" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="PrepareMSBuildExtensionsProps">
|
||||
<PropertyGroup>
|
||||
<MSBuildExtensionsPackageName>Microsoft.NET.Build.Extensions</MSBuildExtensionsPackageName>
|
||||
<MSBuildExtensionsVersionSubfolder>15.0</MSBuildExtensionsVersionSubfolder>
|
||||
<MSBuildExtensionsNuPkgPath>$(NuGetPackagesDir)/$(MSBuildExtensionsPackageName.ToLower())/$(CLI_MSBuildExtensions_Version.ToLower())</MSBuildExtensionsNuPkgPath>
|
||||
|
||||
<NETStandardLibraryNETFrameworkPackageName>NETStandard.Library.NETFramework</NETStandardLibraryNETFrameworkPackageName>
|
||||
<NETStandardLibraryNETFrameworkNuPkgPath>$(NuGetPackagesDir)/$(NETStandardLibraryNETFrameworkPackageName.ToLower())/$(CLI_NETStandardLibraryNETFrameworkVersion.ToLower())</NETStandardLibraryNETFrameworkNuPkgPath>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="RestoreMSBuildExtensionsPackages"
|
||||
DependsOnTargets="PrepareMSBuildExtensionsProps">
|
||||
<ItemGroup>
|
||||
<ExtensionPackageToRestore Include="$(MSBuildExtensionsPackageName)" Version="$(CLI_MSBuildExtensions_Version)"/>
|
||||
<ExtensionPackageToRestore Include="$(NETStandardLibraryNETFrameworkPackageName)" Version="$(CLI_NETStandardLibraryNETFrameworkVersion)"/>
|
||||
|
||||
<ExtensionRestore Include="$(RepoRoot)/build/RestoreDependency.proj">
|
||||
<Properties>
|
||||
CLIBuildDll=$(CLIBuildDll);
|
||||
NuGetPackagesDir=$(NuGetPackagesDir);
|
||||
DependencyPackageName=%(ExtensionPackageToRestore.Identity);
|
||||
DependencyPackageVersion=%(ExtensionPackageToRestore.Version);
|
||||
Stage0Directory=$(Stage0Directory)
|
||||
</Properties>
|
||||
</ExtensionRestore>
|
||||
</ItemGroup>
|
||||
|
||||
<MSBuild
|
||||
BuildInParallel="False"
|
||||
Projects="@(ExtensionRestore)">
|
||||
</MSBuild>
|
||||
</Target>
|
||||
|
||||
<Target Name="GenerateBundledVersionsProps">
|
||||
<PropertyGroup>
|
||||
<BundledVersionsPropsFileName>Microsoft.NETCoreSdk.BundledVersions.props</BundledVersionsPropsFileName>
|
||||
|
|
46
build/RestoreDependency.proj
Normal file
46
build/RestoreDependency.proj
Normal file
|
@ -0,0 +1,46 @@
|
|||
<Project ToolsVersion="15.0" DefaultTargets="EnsureDependencyRestored;CopySdkToOutput">
|
||||
<!-- workaround for https://github.com/Microsoft/msbuild/issues/885 -->
|
||||
<!-- renaming the property because the original property is a global property and therefore
|
||||
cannot be redefined at runtime. -->
|
||||
<PropertyGroup>
|
||||
<CLIBuildDllPath>$([MSBuild]::Unescape($(CLIBuildDll)))</CLIBuildDllPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<UsingTask TaskName="DotNetRestore" AssemblyFile="$(CLIBuildDllPath)" />
|
||||
|
||||
<Target Name="CopySdkToOutput"
|
||||
DependsOnTargets="PrepareBundledDependencyProps;
|
||||
EnsureDependencyRestored;
|
||||
GetSdkItemsToCopy"
|
||||
Condition="'$(SdkLayoutDirectory)' != ''"
|
||||
Inputs="@(SdkContent)"
|
||||
Outputs="@(SdkContent->'$(SdkLayoutDirectory)/%(RecursiveDir)%(FileName)%(Extension)')">
|
||||
<Copy SourceFiles="@(SdkContent)"
|
||||
DestinationFiles="@(SdkContent->'$(SdkLayoutDirectory)/%(RecursiveDir)%(FileName)%(Extension)')" />
|
||||
|
||||
<Message Text="Copied Sdk $(DependencyPackageName) from $(DependencyNuPkgPath) to $(SdkLayoutDirectory)."
|
||||
Importance="High" />
|
||||
</Target>
|
||||
|
||||
<Target Name="GetSdkItemsToCopy">
|
||||
<ItemGroup>
|
||||
<SdkContent Include="$(DependencyNuPkgPath)/**/*"
|
||||
Exclude="$(DependencyNuPkgPath)/$(DependencyPackageName).nuspec;
|
||||
$(DependencyNuPkgPath)/$(DependencyPackageName).$(DependencyPackageVersion).nupkg;
|
||||
$(DependencyNuPkgPath)/$(DependencyPackageName).$(DependencyPackageVersion).nupkg.sha512" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="EnsureDependencyRestored"
|
||||
Condition="!Exists('$(DependencyNuPkgPath)/$(DependencyPackageName.ToLower()).nuspec')">
|
||||
<DotNetRestore ToolPath="$(Stage0Directory)"
|
||||
ProjectPath="$(MSBuildThisFileDirectory)/sdks/sdks.csproj"
|
||||
AdditionalParameters="/p:DependencyPackageName=$(DependencyPackageName) /p:DependencyPackageVersion=$(DependencyPackageVersion)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="PrepareBundledDependencyProps">
|
||||
<PropertyGroup>
|
||||
<DependencyNuPkgPath>$(NuGetPackagesDir)/$(DependencyPackageName.ToLower())/$(DependencyPackageVersion.ToLower())</DependencyNuPkgPath>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
</Project>
|
|
@ -8,7 +8,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="$(SdkPackageName)" Version="$(SdkPackageVersion)" />
|
||||
<PackageReference Include="$(DependencyPackageName)" Version="$(DependencyPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
|
|
@ -112,9 +112,14 @@
|
|||
DependsOnTargets="GenerateMSBuildExtensions"
|
||||
AfterTargets="Publish"
|
||||
BeforeTargets="GenerateCliRuntimeConfigurationFiles">
|
||||
<ItemGroup>
|
||||
<MSBuildExtensionsContent Update="@(MSBuildExtensionsContent)">
|
||||
<DestinationPath Condition="'%(MSBuildExtensionsContent.DestinationPath)' == ''">$(PublishDir)/%(MSBuildExtensionsContent.DeploymentSubpath)%(RecursiveDir)%(Filename)%(Extension)</DestinationPath>
|
||||
</MSBuildExtensionsContent>
|
||||
</ItemGroup>
|
||||
|
||||
<Copy SourceFiles="@(MSBuildExtensionsContent)"
|
||||
DestinationFolder="$(PublishDir)/%(RecursiveDir)" />
|
||||
DestinationFiles="%(MSBuildExtensionsContent.DestinationPath)" />
|
||||
|
||||
<PropertyGroup>
|
||||
<MSBuildTargetsDirectory>$(PublishDir)/runtimes/any/native</MSBuildTargetsDirectory>
|
||||
|
@ -140,13 +145,13 @@
|
|||
<Target Name="PublishSdks"
|
||||
AfterTargets="Publish">
|
||||
<ItemGroup>
|
||||
<SdksToBundle Include="$(RepoRoot)/build/BundledSdks.proj">
|
||||
<SdksToBundle Include="$(RepoRoot)/build/RestoreDependency.proj">
|
||||
<Properties>
|
||||
CLIBuildDll=$(CLIBuildDll);
|
||||
NuGetPackagesDir=$(NuGetPackagesDir);
|
||||
SdkLayoutDirectory=$(SdkOutputDirectory)/Sdks/%(BundledSdk.Identity);
|
||||
SdkPackageName=%(BundledSdk.Identity);
|
||||
SdkPackageVersion=%(BundledSdk.Version);
|
||||
DependencyPackageName=%(BundledSdk.Identity);
|
||||
DependencyPackageVersion=%(BundledSdk.Version);
|
||||
Stage0Directory=$(Stage0Directory)
|
||||
</Properties>
|
||||
</SdksToBundle>
|
||||
|
@ -189,6 +194,12 @@
|
|||
<ItemGroup>
|
||||
<!-- Removing Full CLR built TestHost assemblies from getting Crossgen as it is throwing error -->
|
||||
<SdkFiles Include="$(PublishDir)/**/*" Exclude="$(PublishDir)/TestHost*/**/*;$(PublishDir)/Sdks/**/*" />
|
||||
|
||||
<!-- Don't try to CrossGen .NET Framework support assemblies for .NET Standard -->
|
||||
<SdkFiles Remove="$(PublishDir)/Microsoft.NET.Build.Extensions\net*\**\*" />
|
||||
|
||||
<!-- Don't try to CrossGen tasks and supporting DLLs compiled for .NET Framework -->
|
||||
<SdkFiles Remove="$(PublishDir)/Microsoft.NET.Build.Extensions\tools\net*\**\*" />
|
||||
</ItemGroup>
|
||||
|
||||
<AddMetadataIsPE Items="@(SdkFiles)">
|
||||
|
|
40
test/EndToEnd/GivenNetFrameworkSupportsNetStandard2.cs
Normal file
40
test/EndToEnd/GivenNetFrameworkSupportsNetStandard2.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using FluentAssertions;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace EndToEnd
|
||||
{
|
||||
public class GivenNetFrameworkSupportsNetStandard2 : TestBase
|
||||
{
|
||||
[WindowsOnlyFact]
|
||||
public void ANET461ProjectCanReferenceANETStandardProject()
|
||||
{
|
||||
var _testInstance = TestAssets.Get(TestAssetKinds.DesktopTestProjects, "NETFrameworkReferenceNETStandard20")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles();
|
||||
|
||||
string projectDirectory = Path.Combine(_testInstance.Root.FullName, "TestApp");
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
new BuildCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
new RunCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("This string came from the test library!");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue