Modernize build system (use Directory.Build.* and KoreBuild lineups)

This commit is contained in:
Steve Sanderson 2017-08-30 14:46:37 +01:00
parent 0dfb43b15a
commit 1255418146
21 changed files with 116 additions and 108 deletions

3
Directory.Build.props Normal file
View File

@ -0,0 +1,3 @@
<Project>
<Import Project="version.xml" />
</Project>

14
Directory.Build.targets Normal file
View File

@ -0,0 +1,14 @@
<Project InitialTargets="EnsureKoreBuildRestored">
<Target Name="EnsureKoreBuildRestored" Condition=" '$(KoreBuildRestoreTargetsImported)' != 'true' AND '$(MSBuildProjectName)' != 'BenchmarkDotNet.Autogenerated'">
<PropertyGroup>
<_BootstrapperFile Condition=" $([MSBuild]::IsOSUnixLike()) ">build.sh</_BootstrapperFile>
<_BootstrapperFile Condition="! $([MSBuild]::IsOSUnixLike()) ">build.cmd</_BootstrapperFile>
<_BootstrapperError>
Package references have not been pinned. Run './$(_BootstrapperFile) /t:Pin'.
Also, you can run './$(_BootstrapperFile) /t:Restore' which will pin *and* restore packages. '$(_BootstrapperFile)' can be found in '$(MSBuildThisFileDirectory)'.
</_BootstrapperError>
</PropertyGroup>
<Error Code="KRB1001" Text="$(_BootstrapperError.Trim())" />
</Target>
</Project>

View File

@ -3,7 +3,6 @@
<packageSources>
<clear />
<add key="AspNetCore" value="https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json" />
<add key="AspNetCoreTools" value="https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

View File

@ -3,28 +3,47 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Templates", "src\Templates.csproj", "{1CAB59EF-8E8F-4708-8579-3F5B2D33EB90}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Templates.Test", "test\Templates.Test.csproj", "{D43A4D24-D514-44C2-9438-54F6EDF58680}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Web.ItemTemplates", "src\Microsoft.DotNet.Web.ItemTemplates\Microsoft.DotNet.Web.ItemTemplates.csproj", "{ABC9D95C-7FBD-4F8D-827A-00942EA3D0C0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Web.ProjectTemplates.1.x", "src\Microsoft.DotNet.Web.ProjectTemplates.1.x\Microsoft.DotNet.Web.ProjectTemplates.1.x.csproj", "{B8EB8821-9B58-465A-9693-5F9289AA7B29}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Web.ProjectTemplates.2.0", "src\Microsoft.DotNet.Web.ProjectTemplates.2.0\Microsoft.DotNet.Web.ProjectTemplates.2.0.csproj", "{62D00388-8824-4661-8CC8-8D8436FF97E6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TemplatePackages", "TemplatePackages", "{0AD6E692-E423-408C-B523-DAFB19412E4B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1CAB59EF-8E8F-4708-8579-3F5B2D33EB90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1CAB59EF-8E8F-4708-8579-3F5B2D33EB90}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1CAB59EF-8E8F-4708-8579-3F5B2D33EB90}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1CAB59EF-8E8F-4708-8579-3F5B2D33EB90}.Release|Any CPU.Build.0 = Release|Any CPU
{D43A4D24-D514-44C2-9438-54F6EDF58680}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D43A4D24-D514-44C2-9438-54F6EDF58680}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D43A4D24-D514-44C2-9438-54F6EDF58680}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D43A4D24-D514-44C2-9438-54F6EDF58680}.Release|Any CPU.Build.0 = Release|Any CPU
{ABC9D95C-7FBD-4F8D-827A-00942EA3D0C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ABC9D95C-7FBD-4F8D-827A-00942EA3D0C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ABC9D95C-7FBD-4F8D-827A-00942EA3D0C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ABC9D95C-7FBD-4F8D-827A-00942EA3D0C0}.Release|Any CPU.Build.0 = Release|Any CPU
{B8EB8821-9B58-465A-9693-5F9289AA7B29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8EB8821-9B58-465A-9693-5F9289AA7B29}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8EB8821-9B58-465A-9693-5F9289AA7B29}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8EB8821-9B58-465A-9693-5F9289AA7B29}.Release|Any CPU.Build.0 = Release|Any CPU
{62D00388-8824-4661-8CC8-8D8436FF97E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62D00388-8824-4661-8CC8-8D8436FF97E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62D00388-8824-4661-8CC8-8D8436FF97E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62D00388-8824-4661-8CC8-8D8436FF97E6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{ABC9D95C-7FBD-4F8D-827A-00942EA3D0C0} = {0AD6E692-E423-408C-B523-DAFB19412E4B}
{B8EB8821-9B58-465A-9693-5F9289AA7B29} = {0AD6E692-E423-408C-B523-DAFB19412E4B}
{62D00388-8824-4661-8CC8-8D8436FF97E6} = {0AD6E692-E423-408C-B523-DAFB19412E4B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E9B27B0D-4F85-431B-9C26-80CFE4393D36}
EndGlobalSection

Binary file not shown.

View File

@ -1,9 +0,0 @@
<Project>
<Import Project="..\version.xml" />
<PropertyGroup>
<PackageOutputPath Condition="'$(PackageOutputPath)' == ''">$(MSBuildThisFileDirectory)..\artifacts\</PackageOutputPath>
<PackageVersion Condition="'$(VersionSuffix)' == ''">$(VersionPrefix)</PackageVersion>
<PackageVersion Condition="'$(VersionSuffix)' != ''">$(VersionPrefix)-$(VersionSuffix)</PackageVersion>
</PropertyGroup>
</Project>

View File

@ -1,8 +0,0 @@
<Project>
<PropertyGroup>
<InternalAspNetCoreSdkVersion>2.1.1-*</InternalAspNetCoreSdkVersion>
<TestSdkVersion>15.3.0</TestSdkVersion>
<XunitVersion>2.3.0-beta4-build3742</XunitVersion>
<XunitAnalyzersVersion>0.6.1</XunitAnalyzersVersion>
</PropertyGroup>
</Project>

6
build/repo.props Normal file
View File

@ -0,0 +1,6 @@
<Project>
<ItemGroup>
<PackageLineup Include="Internal.AspNetCore.Universe.Lineup" Version="2.1.0-*" />
<PackageLineup Include="Internal.AspNetCore.Partners.Lineup" Version="2.1.0-*" />
</ItemGroup>
</Project>

33
src/Directory.Build.props Normal file
View File

@ -0,0 +1,33 @@
<Project>
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<EnableDefaultItems>False</EnableDefaultItems>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<IncludeBuildOutput>False</IncludeBuildOutput>
<IncludeSource>False</IncludeSource>
<NoWarn>2008;8021</NoWarn>
<PackageVersion Condition="'$(VersionSuffix)' == ''">$(VersionPrefix)</PackageVersion>
<PackageVersion Condition="'$(VersionSuffix)' != ''">$(VersionPrefix)-$(VersionSuffix)</PackageVersion>
<PackageOutputPath Condition="'$(PackageOutputPath)' == ''">$(MSBuildThisFileDirectory)..\artifacts\</PackageOutputPath>
<NuspecProperties>version=$(PackageVersion)</NuspecProperties>
<!--
These are not regular projects. They are just wrappers for the .nuspec files in each
of the template directories. The project files just provide a convenient way to package
the template .nupkgs from MSBuild.
As such, the projects don't have any dependencies and don't even produce any
.NET assemblies on build. So it's not relevant to participate in KoreBuild's lineup
system. The following line bypasses lineup verification.
-->
<KoreBuildRestoreTargetsImported>true</KoreBuildRestoreTargetsImported>
</PropertyGroup>
<ItemGroup>
<PackageReference Remove="Microsoft.NETCore.App" />
<None Include="Content/**" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<NuspecFile>Microsoft.DotNet.Web.ItemTemplates.nuspec</NuspecFile>
</PropertyGroup>
</Project>

View File

@ -1,19 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<NuspecFile>$(MSBuildThisFileDirectory)\Templates.nuspec</NuspecFile>
<NuspecProperties>version=$(PackageVersion)</NuspecProperties>
<IncludeBuildOutput>False</IncludeBuildOutput>
<IncludeBuildOutput>False</IncludeBuildOutput>
<IncludeSource>False</IncludeSource>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<OutputPath>$(TemplatesFolder)</OutputPath>
<EnableDefaultItems>False</EnableDefaultItems>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\..\artifacts\scratch</BaseIntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Remove="Microsoft.NETCore.App" />
<None Remove="**/*.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<NuspecFile>Microsoft.DotNet.Web.ProjectTemplates.1.x.nuspec</NuspecFile>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<NuspecFile>$(MSBuildThisFileDirectory)\Templates.nuspec</NuspecFile>
<NuspecProperties>version=$(PackageVersion)</NuspecProperties>
<IncludeBuildOutput>False</IncludeBuildOutput>
<IncludeBuildOutput>False</IncludeBuildOutput>
<IncludeSource>False</IncludeSource>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<OutputPath>$(TemplatesFolder)</OutputPath>
<EnableDefaultItems>False</EnableDefaultItems>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\..\artifacts\scratch</BaseIntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Remove="Microsoft.NETCore.App" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<NuspecFile>Microsoft.DotNet.Web.ProjectTemplates.2.0.nuspec</NuspecFile>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<NuspecFile>$(MSBuildThisFileDirectory)\Templates.nuspec</NuspecFile>
<NuspecProperties>version=$(PackageVersion)</NuspecProperties>
<IncludeBuildOutput>False</IncludeBuildOutput>
<IncludeBuildOutput>False</IncludeBuildOutput>
<IncludeSource>False</IncludeSource>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<OutputPath>$(TemplatesFolder)</OutputPath>
<EnableDefaultItems>False</EnableDefaultItems>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\..\artifacts\scratch</BaseIntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Remove="Microsoft.NETCore.App" />
</ItemGroup>
</Project>

View File

@ -1,23 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="**/*" />
</ItemGroup>
<ItemGroup>
<TemplatePack Include="Microsoft.DotNet.Web.ItemTemplates" />
<TemplatePack Include="Microsoft.DotNet.Web.ProjectTemplates.1.x" />
<TemplatePack Include="Microsoft.DotNet.Web.ProjectTemplates.2.0" />
</ItemGroup>
<Target Name="BuildTemplatePackages" BeforeTargets="Build" Outputs="%(TemplatePack.Identity)">
<Message Importance="high" Text="Building %(TemplatePack.Identity)..." />
<MSBuild Targets="Restore;Pack" Projects="%(TemplatePack.FullPath)\build.csproj" Properties="NoWarn=2008" />
<RemoveDir Directories="..\artifacts\scratch;..\artifacts\templates\netstandard1.0" />
</Target>
</Project>

View File

@ -26,6 +26,12 @@ namespace Templates.Test
var basePath = Path.GetDirectoryName(assemblyUri.LocalPath);
TemplateOutputDir = Path.Combine(basePath, "TestTemplates", ProjectName);
Directory.CreateDirectory(TemplateOutputDir);
// We don't want any of the host repo's build config interfering with
// how the test project is built, so disconnect it from the
// Directory.Build.props/targets context
File.WriteAllText(Path.Combine(TemplateOutputDir, "Directory.Build.props"), "<Project />");
File.WriteAllText(Path.Combine(TemplateOutputDir, "Directory.Build.targets"), "<Project />");
}
protected void InstallTemplatePackages()

View File

@ -1,16 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\build\dependencies.props" />
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="Internal.AspNetCore.Sdk" Version="$(InternalAspNetCoreSdkVersion)" PrivateAssets="All" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.analyzers" Version="$(XunitAnalyzersVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Internal.AspNetCore.Sdk" PrivateAssets="All" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.analyzers" />
<PackageReference Include="xunit.runner.visualstudio" />
</ItemGroup>
</Project>