Include Microsoft.Net.Sdk in CLI layout (#4895)
* WiP * Update test * Working version of Net SDK * Latest SDK doesn't work as packageref * DCR + PR * Harden CLI tests against #4884
This commit is contained in:
parent
4311926366
commit
d2d0353e60
9 changed files with 114 additions and 20 deletions
|
@ -35,11 +35,11 @@
|
|||
<Error Condition=" '$(MSBuildSDKsPath)' == '' "
|
||||
Text="Expected MSBuildSDKsPath to be set, but it is not." />
|
||||
|
||||
<Error Condition=" !Exists('$(MSBuildSDKsPath)/%(Sdk.Identity)/%(Sdk.Version)/build/InitialImport.props') "
|
||||
Text="Expected '$(MSBuildSDKsPath)/%(Sdk.Identity)/%(Sdk.Version)/build/InitialImport.props' to exist, but it does not. " />
|
||||
<Error Condition=" !Exists('$(MSBuildSDKsPath)/%(Sdk.Identity)/Sdk/Sdk.props') "
|
||||
Text="Expected '$(MSBuildSDKsPath)/%(Sdk.Identity)/Sdk/Sdk.props' to exist, but it does not. " />
|
||||
|
||||
<Error Condition=" !Exists('$(MSBuildSDKsPath)/%(Sdk.Identity)/%(Sdk.Version)/build/FinalImport.targets') "
|
||||
Text="Expected '$(MSBuildSDKsPath)/%(Sdk.Identity)/%(Sdk.Version)/build/FinalImport.targets' to exist, but it does not. " />
|
||||
<Error Condition=" !Exists('$(MSBuildSDKsPath)/%(Sdk.Identity)/Sdk/Sdk.targets') "
|
||||
Text="Expected '$(MSBuildSDKsPath)/%(Sdk.Identity)/Sdk/Sdk.targets' to exist, but it does not. " />
|
||||
|
||||
<Message Importance="low" Text="Message with low importance" />
|
||||
<Message Importance="normal" Text="Message with normal importance" />
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<Project ToolsVersion="14.0" DefaultTargets="Validate">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<Sdk Include="Microsoft.Core.Sdk" Version="1.0.0-RC2" />
|
||||
<Sdk Include="Microsoft.Web.Sdk" Version="1.0.0-RC2" />
|
||||
<Sdk Include="Microsoft.Net.Sdk" Version="$(CLI_NETSDK_Version)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
42
build/Microsoft.DotNet.Cli.BundledSdks.proj
Normal file
42
build/Microsoft.DotNet.Cli.BundledSdks.proj
Normal file
|
@ -0,0 +1,42 @@
|
|||
<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)')" />
|
||||
</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>
|
|
@ -1,6 +1,9 @@
|
|||
<Project ToolsVersion="15.0">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<BundledSdk Include="Microsoft.Core.Sdk" Version="1.0.0-RC2" />
|
||||
<BundledSdk Include="Microsoft.Web.Sdk" Version="1.0.0-RC2" />
|
||||
<!-- CLI cannot use the latest SDK until we move away from SDK PackageRef -->
|
||||
<BundledSdk Include="Microsoft.Net.Sdk" Version="1.0.0-alpha-20161202-1" />
|
||||
<BundledSdk Include="Microsoft.NET.Sdk.Web" Version="$(CLI_WEBSDK_Version)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -244,17 +244,24 @@
|
|||
<Delete Files="@(PdbsToClean)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="PublishSdks">
|
||||
<MakeDir Directories="$(SdkOutputDirectory)/Extensions/%(BundledSdk.Identity)/%(BundledSdk.Version)/build/" />
|
||||
|
||||
<!-- Generate sdk placeholder files -->
|
||||
<WriteLinesToFile File="$(SdkOutputDirectory)/Extensions/%(BundledSdk.Identity)/%(BundledSdk.Version)/build/InitialImport.props"
|
||||
Lines="placeholder"
|
||||
Overwrite="true" />
|
||||
|
||||
<WriteLinesToFile File="$(SdkOutputDirectory)/Extensions/%(BundledSdk.Identity)/%(BundledSdk.Version)/build/FinalImport.targets"
|
||||
Lines="placeholder"
|
||||
Overwrite="true" />
|
||||
<Target Name="PublishSdks"
|
||||
DependsOnTargets="Prepare">
|
||||
<ItemGroup>
|
||||
<SdksToBundle Include="build/Microsoft.DotNet.Cli.BundledSdks.proj">
|
||||
<Properties>
|
||||
CLIBuildDll=$(CLIBuildDll);
|
||||
NuGetPackagesDir=$(NuGetPackagesDir);
|
||||
SdkLayoutDirectory=$(SdkOutputDirectory)/Extensions/%(BundledSdk.Identity);
|
||||
SdkPackageName=%(BundledSdk.Identity);
|
||||
SdkPackageVersion=%(BundledSdk.Version);
|
||||
Stage0Directory=$(Stage0Directory)
|
||||
</Properties>
|
||||
</SdksToBundle>
|
||||
</ItemGroup>
|
||||
|
||||
<MSBuild
|
||||
BuildInParallel="True"
|
||||
Projects="@(SdksToBundle)">
|
||||
</MSBuild>
|
||||
</Target>
|
||||
</Project>
|
|
@ -3,5 +3,6 @@
|
|||
<PropertyGroup>
|
||||
<CLI_MSBuild_Version>15.1.0-preview-000451-02</CLI_MSBuild_Version>
|
||||
<CLI_NETSDK_Version>1.0.0-alpha-20161104-2</CLI_NETSDK_Version>
|
||||
<CLI_WEBSDK_Version>1.0.0-alpha-20161104-2-112</CLI_WEBSDK_Version>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
17
build/sdks/sdks.csproj
Executable file
17
build/sdks/sdks.csproj
Executable file
|
@ -0,0 +1,17 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="$(SdkPackageName)">
|
||||
<Version>$(SdkPackageVersion)</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -12,9 +12,11 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
protected override string Args
|
||||
{
|
||||
get { return $"{GetProjectPath()} {GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()} {GetRuntime()}"; }
|
||||
get { return $"{GetProjectPath()} {GetSource()} {GetPackages()} {GetSkipInvalidConfigurations()} {GetRuntime()} {GetAdditionalParameters()}"; }
|
||||
}
|
||||
|
||||
public string AdditionalParameters { get; set; }
|
||||
|
||||
public string ProjectPath { get; set; }
|
||||
|
||||
public string Source { get; set; }
|
||||
|
@ -74,5 +76,10 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetAdditionalParameters()
|
||||
{
|
||||
return AdditionalParameters;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
private List<Action<string>> _writeLines = new List<Action<string>>();
|
||||
|
||||
private List<string> _cliGeneratedEnvironmentVariables = new List<string> { "MSBuildSDKsPath" };
|
||||
|
||||
public TestCommand(string command)
|
||||
{
|
||||
_command = command;
|
||||
|
@ -178,6 +180,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
UseShellExecute = false
|
||||
};
|
||||
|
||||
RemoveCliGeneratedEnvironmentVariables(psi);
|
||||
|
||||
foreach (var item in Environment)
|
||||
{
|
||||
#if NET451
|
||||
|
@ -219,5 +223,17 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
return $" in pwd {WorkingDirectory}";
|
||||
}
|
||||
|
||||
private void RemoveCliGeneratedEnvironmentVariables(ProcessStartInfo psi)
|
||||
{
|
||||
foreach (var name in _cliGeneratedEnvironmentVariables)
|
||||
{
|
||||
#if NET451
|
||||
psi.EnvironmentVariables.Remove(name);
|
||||
#else
|
||||
psi.Environment.Remove(name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue