aspnetcore/build/repo.targets

336 строки
20 KiB
XML

<Project>
<Import Project="RepositoryBuild.targets" />
<Import Project="PackageArchive.targets" />
<Import Project="SharedFx.targets" />
<Import Project="SharedFxInstaller.targets" />
<Import Project="Publish.targets" />
<Import Project="buildorder.props" />
<PropertyGroup>
<GeneratedPackageVersionPropsPath>$(IntermediateDir)dependencies.g.props</GeneratedPackageVersionPropsPath>
<GeneratedRestoreSourcesPropsPath>$(IntermediateDir)sources.g.props</GeneratedRestoreSourcesPropsPath>
<GeneratedBrandingPropsPath>$(IntermediateDir)branding.g.props</GeneratedBrandingPropsPath>
<PrepareDependsOn>SetTeamCityBuildNumberToVersion;$(PrepareDependsOn)</PrepareDependsOn>
<PrepareDependsOn Condition="'$(_ProjectsOnly)' != 'true'">$(PrepareDependsOn);VerifyPackageArtifactConfig;VerifyExternalDependencyConfig;PrepareOutputPaths</PrepareDependsOn>
<CleanDependsOn>$(CleanDependsOn);CleanArtifacts;CleanRepoArtifacts</CleanDependsOn>
<RestoreDependsOn>$(RestoreDependsOn);InstallDotNet;RestoreProjects</RestoreDependsOn>
<CompileDependsOn>$(CompileDependsOn);BuildProjects;PackSharedSources</CompileDependsOn>
<CompileDependsOn Condition="'$(_ProjectsOnly)' != 'true'">$(CompileDependsOn);PackProjects;BuildRepositories</CompileDependsOn>
<PackageDependsOn Condition=" '$(_ProjectsOnly)' == 'true'">$(PackageDependsOn);PackProjects</PackageDependsOn>
<PackageDependsOn Condition="'$(TestOnly)' != 'true' AND '$(_ProjectsOnly)' != 'true'">$(PackageDependsOn);BuildMetapackages;BuildSiteExtension;CheckExpectedPackagesExist</PackageDependsOn>
<TestDependsOn>$(TestDependsOn);TestProjects</TestDependsOn>
<TestDependsOn Condition="'$(_ProjectsOnly)' != 'true'">$(TestDependsOn);_TestRepositories</TestDependsOn>
<GetArtifactInfoDependsOn Condition="'$(SkipArtifactInfoTargets)' != 'true'">$(GetArtifactInfoDependsOn);GetProjectArtifactInfo</GetArtifactInfoDependsOn>
<GetArtifactInfoDependsOn Condition="'$(SkipArtifactInfoTargets)' != 'true'">$(GetArtifactInfoDependsOn);ResolveSharedSourcesPackageInfo</GetArtifactInfoDependsOn>
<GetArtifactInfoDependsOn Condition="'$(SkipArtifactInfoTargets)' != 'true' AND '$(_ProjectsOnly)' != 'true'">$(GetArtifactInfoDependsOn);ResolveRepoInfo</GetArtifactInfoDependsOn>
</PropertyGroup>
<Target Name="PrepareOutputPaths">
<MakeDir Directories="$(ArtifactsDir);$(BuildDir)" />
</Target>
<Target Name="GenerateProjectList" DependsOnTargets="ResolveProjects">
<MSBuild Projects="@(ProjectToBuild)"
Targets="GetReferencesProvided"
BuildInParallel="true"
SkipNonexistentTargets="true"
SkipNonexistentProjects="true" >
<Output TaskParameter="TargetOutputs" ItemName="_ProjectReferenceProvider"/>
</MSBuild>
<PropertyGroup>
<ProjectListFile>$(MSBuildThisFileDirectory)..\eng\ProjectReferences.props</ProjectListFile>
<ProjectListContent>
<![CDATA[
<!--
This file is automatically generated. Run `build.cmd /t:GenerateProjectList` to update.
This file contains a map of assembly names to the projects that build them.
-->
<Project>
<ItemGroup>
@(_ProjectReferenceProvider->'<ProjectReferenceProvider Include="%(Identity)" ProjectPath="%24(RepositoryRoot)%(ProjectFileRelativePath)" />', '%0A ')
</ItemGroup>
</Project>
]]>
</ProjectListContent>
</PropertyGroup>
<WriteLinesToFile File="$(ProjectListFile)" Lines="$(ProjectListContent)" Overwrite="true" />
</Target>
<Target Name="_ResolveProjectArtifactsInfoShipped" AfterTargets="GetProjectArtifactInfo">
<ItemGroup>
<ShippedArtifactInfo Include="@(ArtifactInfo)" Condition="'%(ArtifactInfo.IsShipped)' == 'true'" />
<ArtifactInfo Remove="@(ShippedArtifactInfo)" />
</ItemGroup>
</Target>
<Target Name="ResolveRepoInfo" DependsOnTargets="_ResolveProjectArtifactsInfoShipped;_PrepareRepositories;GetMetapackageArtifactInfo;GetSiteExtensionArtifactInfo">
<!-- We need to pass the NETCoreApp package versions to msbuild so that it doesn't complain about us using a different one than it was restored against. -->
<PropertyGroup>
<DesignTimeBuildProps>MicrosoftNETCoreAppPackageVersion=$(MicrosoftNETCoreAppPackageVersion);</DesignTimeBuildProps>
<DesignTimeBuildProps>$(DesignTimeBuildProps);MicrosoftNETCoreApp21PackageVersion=$(MicrosoftNETCoreApp21PackageVersion);</DesignTimeBuildProps>
<DesignTimeBuildProps>$(DesignTimeBuildProps);MicrosoftNETCoreApp20PackageVersion=$(MicrosoftNETCoreApp20PackageVersion);</DesignTimeBuildProps>
</PropertyGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="GetArtifactInfo"
Properties="$(DesignTimeBuildProps);RepositoryRoot=%(Repository.RootPath);Configuration=$(Configuration);BuildNumber=$(BuildNumber);DesignTimeBuild=true"
ContinueOnError="WarnAndContinue"
Condition="'%(Repository.Identity)' != ''">
<Output TaskParameter="TargetOutputs" ItemName="ArtifactInfo" />
</MSBuild>
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="ResolveSolutions"
Properties="RepositoryRoot=%(Repository.RootPath);Configuration=$(Configuration);BuildNumber=$(BuildNumber)"
ContinueOnError="WarnAndContinue"
Condition="'%(Repository.Identity)' != ''">
<Output TaskParameter="TargetOutputs" ItemName="Solution" Condition="'%(Repository.Build)' == 'true'" />
<Output TaskParameter="TargetOutputs" ItemName="_NoBuildSolution" Condition="'%(Repository.Build)' != 'true'" />
</MSBuild>
<!--
Analyze what was shipped in these repos.
This is required so we can verify that cascading versions are consistent.
-->
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="GetArtifactInfo"
Properties="$(DesignTimeBuildProps);RepositoryRoot=%(ShippedRepository.RootPath);Configuration=$(Configuration);BuildNumber=$(BuildNumber);IsFinalBuild=true;DesignTimeBuild=true"
ContinueOnError="WarnAndContinue"
Condition="'%(ShippedRepository.Identity)' != ''">
<Output TaskParameter="TargetOutputs" ItemName="ShippedArtifactInfo" />
</MSBuild>
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="ResolveSolutions"
Properties="RepositoryRoot=%(ShippedRepository.RootPath);Configuration=$(Configuration);BuildNumber=$(BuildNumber)"
ContinueOnError="WarnAndContinue"
Condition="'%(ShippedRepository.Identity)' != ''">
<Output TaskParameter="TargetOutputs" ItemName="_ShippedSolution" />
</MSBuild>
<ItemGroup>
<_Temp Remove="@(_Temp)" />
<_Temp Include="@(PackageArtifact)" />
<PackageArtifact Remove="@(PackageArtifact)" />
</ItemGroup>
<!-- Join required because shipping category is stored in artifact.props (PackageArtifact), but information about package ID and version comes from repos (ArtifactInfo). -->
<RepoTasks.JoinItems
Left="@(_Temp)"
LeftMetadata="*"
Right="@(ArtifactInfo->WithMetadataValue('ArtifactType','NuGetPackage'));@(ShippedArtifactInfo->WithMetadataValue('ArtifactType','NuGetPackage'))"
RightKey="PackageId"
RightMetadata="Version">
<Output TaskParameter="JoinResult" ItemName="PackageArtifact" />
</RepoTasks.JoinItems>
<ItemGroup>
<_PackageArtifactWithoutMatchingInfo Include="@(_Temp)" Exclude="@(PackageArtifact)" />
</ItemGroup>
<Error Text="Could not detect version information for package id:%0A * @(_PackageArtifactWithoutMatchingInfo, '%0A * ')"
Condition="@(_PackageArtifactWithoutMatchingInfo->Count()) != 0" />
<ItemGroup>
<!-- Adjust the list of what is considered external vs locally built. -->
<ExternalDependency Include="%(ShippedArtifactInfo.PackageId)" Condition="'%(ShippedArtifactInfo.ArtifactType)' == 'NuGetPackage'">
<Version>%(ShippedArtifactInfo.Version)</Version>
</ExternalDependency>
<!-- capture the original list of PackageArtifacts -->
<_PackageArtifactSpec Include="@(PackageArtifact)" />
<PackageArtifact Remove="%(ShippedArtifactInfo.PackageId)" Condition="'%(ShippedArtifactInfo.ArtifactType)' == 'NuGetPackage'" />
<Solution Update="@(Solution)" Build="true" IsPatching="true" />
<_ShippedSolution Update="@(_ShippedSolution)" Build="false" IsPatching="false" />
<_NoBuildSolution Update="@(_NoBuildSolution)" Build="false" />
<Solution Include="@(_NoBuildSolution);@(_ShippedSolution)" />
</ItemGroup>
<Error Text="No solutions were found in '$(SubmoduleRoot)'. Did you forget to clone the submodules? Run `git submodule update --init`." Condition="@(Solution->Count()) == 0" />
</Target>
<Target Name="GeneratePropsFiles" DependsOnTargets="PrepareOutputPaths;GetArtifactInfo">
<ItemGroup>
<_LineupPackages Include="@(ExternalDependency)" />
<_LineupPackages Include="%(ArtifactInfo.PackageId)" Version="%(ArtifactInfo.Version)" Condition=" '%(ArtifactInfo.ArtifactType)' == 'NuGetPackage' " />
<_RestoreSources Include="$(DependencyPackageDir)" Condition="'$(DependencyPackageDir)' != '' AND Exists('$(DependencyPackageDir)')" />
<_RestoreSources Include="$(SignedDependencyPackageDir)" Condition="'$(SignedDependencyPackageDir)' != '' AND Exists('$(SignedDependencyPackageDir)')" />
<_RestoreSources Include="$(BuildDir)" />
<_RestoreSources Include="$(RestoreSources)" />
</ItemGroup>
<GeneratePackageVersionPropsFile
Packages="@(_LineupPackages)"
OutputPath="$(GeneratedPackageVersionPropsPath)" />
<Copy SourceFiles="$(GeneratedPackageVersionPropsPath)" DestinationFolder="$(ArtifactsDir)" />
<RepoTasks.GenerateRestoreSourcesPropsFile
Sources="@(_RestoreSources)"
OutputPath="$(GeneratedRestoreSourcesPropsPath)" />
<PropertyGroup>
<!-- Generate an MSBuild file that can be imported and used by Windows Installer builds to keep our versions consistent. -->
<BrandingPropsContent>
<![CDATA[
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AspNetCoreMajorVersion>$(AspNetCoreMajorVersion)</AspNetCoreMajorVersion>
<AspNetCoreMinorVersion>$(AspNetCoreMinorVersion)</AspNetCoreMinorVersion>
<AspNetCorePatchVersion>$(AspNetCorePatchVersion)</AspNetCorePatchVersion>
<AspNetCorePreReleaseVersionLabel>$(PreReleaseLabel)</AspNetCorePreReleaseVersionLabel>
<AspNetCoreBuildNumber>$(BuildNumber)</AspNetCoreBuildNumber>
<AspNetCoreBrandingVersion>$(PackageBrandingVersion)</AspNetCoreBrandingVersion>
</PropertyGroup>
</Project>
]]>
</BrandingPropsContent>
</PropertyGroup>
<WriteLinesToFile File="$(GeneratedBrandingPropsPath)" Overwrite="true" Lines="$(BrandingPropsContent)"/>
<Copy SourceFiles="$(GeneratedPackageVersionPropsPath);$(GeneratedBrandingPropsPath)" DestinationFolder="$(ArtifactsDir)" />
</Target>
<Target Name="CleanRepoArtifacts">
<RemoveDir Directories="$(RepositoryRoot)obj" Condition="Exists('$(RepositoryRoot)obj')" />
</Target>
<Target Name="_PrepareRepositories">
<ItemGroup>
<Repository Update="%(Identity)" RootPath="$(SubmoduleRoot)%(Identity)\" Condition="'%(Identity)' != '' AND '%(RootPath)' == ''" />
<ShippedRepository Update="%(Identity)" RootPath="$(SubmoduleRoot)%(Identity)\" Condition="'%(Identity)' != '' AND '%(RootPath)' == ''" />
</ItemGroup>
</Target>
<Target Name="BuildRepositories"
DependsOnTargets="_PrepareRepositories;GeneratePropsFiles;ComputeGraph;_BuildRepositories" />
<Target Name="ListExpectedPackages" DependsOnTargets="ResolveSharedSourcesPackageInfo;GetProjectArtifactInfo;ResolveRepoInfo">
<WriteLinesToFile File="$(RepositoryRoot)artifacts\packages.csv" Lines="PackageId,Version;@(ArtifactInfo->WithMetadataValue('ArtifactType', 'NuGetPackage')->'%(PackageId),%(Version)')" Overwrite="true" />
</Target>
<Target Name="ComputeGraph" DependsOnTargets="ResolveSharedSourcesPackageInfo;GetProjectArtifactInfo;ResolveRepoInfo;GeneratePropsFiles">
<ItemGroup>
<_UndeclaredPackageArtifact Include="%(ArtifactInfo.PackageId)" Condition="'%(ArtifactInfo.ArtifactType)' == 'NuGetPackage'" />
<_UndeclaredPackageArtifact Remove="@(PackageArtifact)" />
<RepositoryBuildOrder Remove="@(ShippedRepository)" />
</ItemGroup>
<Error Text="Undeclared package artifacts. Add these to artifacts.props:%0A - @(_UndeclaredPackageArtifact, '%0A - ')"
Condition=" @(_UndeclaredPackageArtifact->Count()) != 0 " />
<Message Text="Repository build order:" Importance="high" />
<Message Text="%(RepositoryBuildOrder.Order). @(RepositoryBuildOrder, ', ')" Importance="high" />
</Target>
<Target Name="VerifyPackageArtifactConfig">
<Error Text="Invalid configuration of %(PackageArtifact.Identity). PackageArtifact must have the 'Category' metadata."
Condition="'%(PackageArtifact.Category)' == '' " />
<Error Text="Invalid configuration of %(PackageArtifact.Identity). Packages marked as LZMA='true' must be Category='ship'."
Condition="'%(PackageArtifact.Category)' != 'ship' AND '%(PackageArtifact.LZMA)' == 'true' " />
<Error Text="Invalid configuration of %(PackageArtifact.Identity). Packages marked as AppMetapackage='true' must be Category='ship'."
Condition="'%(PackageArtifact.Category)' != 'ship' AND '%(PackageArtifact.AppMetapackage)' == 'true' " />
<Error Text="Invalid configuration of %(PackageArtifact.Identity). Packages marked as AllMetapackage='true' must be Category='ship'."
Condition="'%(PackageArtifact.Category)' != 'ship' AND '%(PackageArtifact.AllMetapackage)' == 'true' " />
<Error Text="Invalid configuration of %(PackageArtifact.Identity). Packages marked as AppMetapackage='true' must also be marked as AllMetapackage='true'."
Condition="'%(PackageArtifact.AppMetapackage)' == 'true' AND '%(PackageArtifact.AllMetapackage)' != 'true' " />
</Target>
<Target Name="VerifyExternalDependencyConfig">
<RepoTasks.CheckVersionOverrides DotNetPackageVersionPropsPath="$(DotNetPackageVersionPropsPath)"
DependenciesFile="$(MSBuildThisFileDirectory)dependencies.props"
Condition="'$(DotNetPackageVersionPropsPath)' != ''" />
<Error Text="Missing Version metadata for the following external dependencies: %0A - @(ExternalDependency->WithMetadataValue('Version', ''), '%0A - '). "
Condition=" @(ExternalDependency->WithMetadataValue('Version', '')->Count()) != 0 " />
</Target>
<Target Name="FastCheck"
DependsOnTargets="ComputeGraph;VerifyPackageArtifactConfig;VerifyAllReposHaveNuGetPackageVerifier" />
<Target Name="CheckExpectedPackagesExist">
<ItemGroup>
<PackageArtifactFile Include="$(BuildDir)*.nupkg" Exclude="$(BuildDir)*.symbols.nupkg" />
</ItemGroup>
<RepoTasks.CheckExpectedPackagesExist Packages="@(PackageArtifact)" Files="@(PackageArtifactFile)" />
</Target>
<Target Name="VerifyAllReposHaveNuGetPackageVerifier" DependsOnTargets="_PrepareRepositories">
<Error Condition="'%(Repository.Identity)' != '' AND !Exists('%(Repository.RootPath)NuGetPackageVerifier.json')"
Text="Repository %(Repository.Identity) is missing NuGetPackageVerifier.json. Expected file to exist in %(Repository.RootPath)NuGetPackageVerifier.json" />
</Target>
<Target Name="DoCodeSigning" DependsOnTargets="_SetupCodeSign;CodeSign;_CopySignedFilesToArtifacts" />
<Target Name="_SetupCodeSign">
<PropertyGroup>
<!-- Make sure we're not disabling code signing -->
<DisableCodeSigning>false</DisableCodeSigning>
</PropertyGroup>
<ItemGroup>
<!-- We're passing a custom list of files - clear out the exclusion list so it doesn't interfere -->
<FilesToExcludeFromSigning Remove="@(FilesToExcludeFromSigning)" />
<!-- Make sure 3rd party binaries get 3rd party certificate -->
<CustomFileSignInfo Include="MsgPack.dll" CertificateName="3PartySHA2" />
<CustomFileSignInfo Include="MessagePack.dll" CertificateName="3PartySHA2" />
<CustomFileSignInfo Include="Newtonsoft.Json.Bson.dll" CertificateName="3PartySHA2" />
<CustomFileSignInfo Include="Newtonsoft.Json.dll" CertificateName="3PartySHA2" />
<CustomFileSignInfo Include="Remotion.Linq.dll" CertificateName="3PartySHA2" />
<CustomFileSignInfo Include="SQLitePCLRaw.batteries_green.dll" CertificateName="3PartySHA2" />
<CustomFileSignInfo Include="SQLitePCLRaw.batteries_v2.dll" CertificateName="3PartySHA2" />
<CustomFileSignInfo Include="SQLitePCLRaw.core.dll" CertificateName="3PartySHA2" />
<CustomFileSignInfo Include="SQLitePCLRaw.provider.e_sqlite3.dll" CertificateName="3PartySHA2" />
<CustomFileSignInfo Include="e_sqlite3.dll" CertificateName="3PartySHA2" />
<CustomFileSignInfo Include="StackExchange.Redis.StrongName.dll" CertificateName="3PartySHA2" />
<CustomFileSignInfo Include="System.Interactive.Async.dll" CertificateName="3PartySHA2" />
<!--
Map file extensions to a code-sign cert.
"None" means don't sign the file itself, but still scan the contents for signable files.
-->
<CustomFileExtensionSignInfo Include=".ps1;.psd1;.psm1;.psc1" CertificateName="Microsoft400" />
<CustomFileExtensionSignInfo Include=".dll;.exe" CertificateName="MicrosoftSHA2" />
<CustomFileExtensionSignInfo Include=".cab" CertificateName="None" />
<!-- We don't need to code sign .js files because they are not used in Windows Script Host. -->
<CustomFileExtensionSignInfo Include=".js" CertificateName="None" />
<!-- We don't produce font files. We rebundle some for using the web brower, so they do not need to be signed. -->
<CustomFileExtensionSignInfo Include=".otf" CertificateName="None" />
<CustomFileExtensionSignInfo Include=".ttf" CertificateName="None" />
<!-- This is a text file which doesn't need to be code signed, even though some .mof files can be signed. -->
<CustomFileSignInfo Include="ancm.mof" CertificateName="None" />
<!-- Exclude the apphost because this is expected to be code-signed by customers after the SDK modifies it. -->
<CustomFileSignInfo Include="apphost.exe" CertificateName="None" />
<FilesToSign Include="$(DependencyPackageDir)**\*.nupkg" Certificate="NuGet" />
<FilesToSign Include="$(DependencyPackageDir)**\*.mpack" Certificate="None" />
<FilesToSign Include="$(DependencyPackageDir)**\*.vsix" Certificate="VsixSHA2" />
<FilesToSign Include="$(DependencyPackageDir)**\*.jar" Certificate="MicrosoftJARSHA2" />
<FilesToSign Include="$(ArtifactsDir)symbols\**\*.nupkg" Certificate="NuGet" />
<FilesToSign Include="$(SharedFxOutputPath)**\*.zip" Certificate="None" />
</ItemGroup>
</Target>
<Target Name="_CopySignedFilesToArtifacts">
<Copy SourceFiles="%(FilesToSign.Identity)" DestinationFiles="$(ArtifactsDir)Signed\MPacks\%(FilesToSign.Filename)%(FilesToSign.Extension)" Condition="'%(FilesToSign.Extension)' == '.mpack'" />
<Copy SourceFiles="%(FilesToSign.Identity)" DestinationFiles="$(ArtifactsDir)Signed\Packages\%(FilesToSign.Filename)%(FilesToSign.Extension)" Condition="'%(FilesToSign.Extension)' == '.nupkg'" />
<Copy SourceFiles="%(FilesToSign.Identity)" DestinationFiles="$(ArtifactsDir)Signed\Packages\%(FilesToSign.Filename)%(FilesToSign.Extension)" Condition="'%(FilesToSign.Extension)' == '.jar'" />
<Copy SourceFiles="%(FilesToSign.Identity)" DestinationFiles="$(ArtifactsDir)Signed\VSIX\%(FilesToSign.Filename)%(FilesToSign.Extension)" Condition="'%(FilesToSign.Extension)' == '.vsix'" />
<Copy SourceFiles="%(FilesToSign.Identity)" DestinationFiles="$(ArtifactsDir)Signed\SharedFx\%(FilesToSign.Filename)%(FilesToSign.Extension)" Condition="'%(FilesToSign.Extension)' == '.zip'" />
</Target>
</Project>