700 lines
37 KiB
XML
700 lines
37 KiB
XML
<Project>
|
|
|
|
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)..))" />
|
|
|
|
<PropertyGroup Condition="'$(UseInnerClone)' == 'true'">
|
|
<BuildArgs>$(BuildArgs) /p:UseInnerClone=true</BuildArgs>
|
|
<BuildArgs>$(BuildArgs) /p:CopySrcInsteadOfClone=true</BuildArgs>
|
|
<BuildArgs>$(BuildArgs) /p:CopyWipIntoInnerSourceBuildRepo=true</BuildArgs>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<!-- Force use of dotnet msbuild (ignoring global.json contents) unless BuildWithDesktopMSBuild is explicitly set in the repo project. -->
|
|
<BuildArgs Condition="'$(BuildOS)' == 'windows' and '$(BuildWithDesktopMSBuild)' != 'true'">$(BuildArgs) $(FlagParameterPrefix)msbuildEngine dotnet</BuildArgs>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<BuildCommand Condition="'$(BuildCommand)' == '' and '$(IsUtilityProject)' != 'true'">$(BuildScript) $(BuildActions) $(BuildArgs)</BuildCommand>
|
|
|
|
<!-- The default PackageVersionPropsFlowType behavior (DependenciesOnly) triggers logic that looks for a
|
|
Version.Details.xml file. Setting the type to AllPackages will skip that logic. -->
|
|
<PackageVersionPropsFlowType Condition="'$(IsUtilityProject)' == 'true'">AllPackages</PackageVersionPropsFlowType>
|
|
|
|
<!-- MinimalConsoleLogOutput determines if the repository build should be logged to a separate file or directly to the console. -->
|
|
<RepoConsoleLogFile>$(ArtifactsLogDir)$(RepositoryName).log</RepoConsoleLogFile>
|
|
<MinimalConsoleLogOutput Condition="'$(MinimalConsoleLogOutput)' == '' and '$(ContinuousIntegrationBuild)' == 'true'">true</MinimalConsoleLogOutput>
|
|
|
|
<PackageReportDataFile>$(PackageReportDir)prebuilt-usage.xml</PackageReportDataFile>
|
|
<ProjectAssetsJsonArchiveFile>$(PackageReportDir)all-project-assets-json-files.zip</ProjectAssetsJsonArchiveFile>
|
|
<ProdConManifestFile>$(PackageReportDir)prodcon-build.xml</ProdConManifestFile>
|
|
<RepoManifestFile>$([MSBuild]::NormalizePath('$(ProjectDirectory)', 'artifacts', 'RepoManifest.xml'))</RepoManifestFile>
|
|
|
|
<IntermediateSymbolsRepoDir>$(IntermediateSymbolsRootDir)$(RepositoryName)</IntermediateSymbolsRepoDir>
|
|
</PropertyGroup>
|
|
|
|
<!-- Exclude repositories that currently don't build when not building source-only. -->
|
|
<ItemGroup Condition="'$(DotNetBuildSourceOnly)' != 'true'">
|
|
<RepositoryReference Remove="roslyn" />
|
|
<RepositoryReference Remove="msbuild" />
|
|
<RepositoryReference Remove="sdk" />
|
|
<RepositoryReference Remove="aspnetcore" />
|
|
<RepositoryReference Remove="razor" />
|
|
<RepositoryReference Remove="deployment-tools" />
|
|
<RepositoryReference Remove="format" />
|
|
<RepositoryReference Remove="nuget-client" />
|
|
<RepositoryReference Remove="test-templates" />
|
|
<RepositoryReference Remove="fsharp" />
|
|
<RepositoryReference Remove="vstest" />
|
|
<RepositoryReference Remove="aspire" />
|
|
<RepositoryReference Remove="installer" />
|
|
</ItemGroup>
|
|
|
|
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="AddSourceToNuGetConfig" />
|
|
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="RemoveInternetSourcesFromNuGetConfig" />
|
|
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="UpdateJson" />
|
|
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="UpdateNuGetConfigPackageSourcesMappings" />
|
|
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="ValidateUsageAgainstBaseline" />
|
|
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="WritePackageVersionsProps" />
|
|
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="WritePackageUsageData" />
|
|
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="WriteUsageReports" />
|
|
|
|
<Target Name="CopyNuGetConfig"
|
|
Condition="'$(NuGetConfigFile)' != ''"
|
|
Inputs="$(MSBuildProjectFullPath);$(OriginalNuGetConfigFile)"
|
|
Outputs="$(NuGetConfigFile)">
|
|
|
|
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('$(NuGetConfigFile)'))" />
|
|
|
|
<Copy
|
|
SourceFiles="$(OriginalNuGetConfigFile)"
|
|
DestinationFiles="$(NuGetConfigFile)">
|
|
<Output TaskParameter="CopiedFiles" ItemName="FileWrites" />
|
|
</Copy>
|
|
</Target>
|
|
|
|
<Target Name="UpdateNuGetConfig"
|
|
DependsOnTargets="CopyNuGetConfig"
|
|
Condition="'$(NuGetConfigFile)' != ''"
|
|
Inputs="$(MSBuildProjectFullPath)"
|
|
Outputs="$(BaseIntermediateOutputPath)UpdateNuGetConfig.complete">
|
|
<PropertyGroup>
|
|
<!-- Feed for the shipping live built packages -->
|
|
<SourceBuiltShippingNuGetSourceName>source-built</SourceBuiltShippingNuGetSourceName>
|
|
<!-- Feed for the non-shipping live built packages -->
|
|
<SourceBuiltNonShippingNuGetSourceName>source-built-transport</SourceBuiltNonShippingNuGetSourceName>
|
|
<SourceBuildSources>$(SourceBuiltShippingNuGetSourceName);$(SourceBuiltNonShippingNuGetSourceName)</SourceBuildSources>
|
|
|
|
<!-- Dev innerloop opt-in feed: /p:ExtraRestoreSourcePath=... -->
|
|
<ExtraSourcesNuGetSourceName>ExtraSources</ExtraSourcesNuGetSourceName>
|
|
<SourceBuildSources Condition="'$(ExtraRestoreSourcePath)' != ''">$(SourceBuildSources);$(ExtraSourcesNuGetSourceName)</SourceBuildSources>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(DotNetBuildSourceOnly)' == 'true'">
|
|
<PrebuiltNuGetSourceName>prebuilt</PrebuiltNuGetSourceName>
|
|
<PreviouslySourceBuiltNuGetSourceName>previously-source-built</PreviouslySourceBuiltNuGetSourceName>
|
|
<ReferencePackagesNuGetSourceName>reference-packages</ReferencePackagesNuGetSourceName>
|
|
<SourceBuildSources>$(SourceBuildSources);$(PrebuiltNuGetSourceName);$(PreviouslySourceBuiltNuGetSourceName);$(ReferencePackagesNuGetSourceName)</SourceBuildSources>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(DotNetBuildSourceOnly)' != 'true'">
|
|
<!-- When not building source-only, repositories lagging behind on the .NET SDK (e.g. tooling repos)
|
|
that need to utilize a VS-aligned version for development purposes may not have the latest product
|
|
daily build feed in their NuGet.config. This means that when a newer globally-specified .NET SDK
|
|
attempts to restore shared framework packages, they will not be found. Work around this by
|
|
ensuring that repos have the supporting SDK feed. Note that this is not required when the SDK
|
|
in use is a released SDK.
|
|
|
|
Currently we are using a preview .NET 9 SDK and not all repos are using the Net 9 SDK
|
|
If either of these are not true, set below to false.
|
|
-->
|
|
<AddNetSdkSupportingFeed>true</AddNetSdkSupportingFeed>
|
|
<NetSdkSupportingFeedName>net-sdk-supporting-feed</NetSdkSupportingFeedName>
|
|
<NetSdkSupportingFeed>https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json</NetSdkSupportingFeed>
|
|
</PropertyGroup>
|
|
|
|
<RemoveInternetSourcesFromNuGetConfig
|
|
NuGetConfigFile="$(NuGetConfigFile)"
|
|
BuildWithOnlineFeeds="$(DotNetBuildWithOnlineFeeds)"
|
|
KeepFeedPrefixes="@(KeepFeedPrefixes)"
|
|
Condition="'$(DotNetBuildSourceOnly)' == 'true'" />
|
|
|
|
<AddSourceToNuGetConfig NuGetConfigFile="$(NuGetConfigFile)"
|
|
SourceName="$(PrebuiltNuGetSourceName)"
|
|
SourcePath="$(PrebuiltPackagesPath)"
|
|
Condition="'$(DotNetBuildSourceOnly)' == 'true'" />
|
|
|
|
<AddSourceToNuGetConfig NuGetConfigFile="$(NuGetConfigFile)"
|
|
SourceName="$(PreviouslySourceBuiltNuGetSourceName)"
|
|
SourcePath="$(PrebuiltSourceBuiltPackagesPath)"
|
|
Condition="'$(DotNetBuildSourceOnly)' == 'true'" />
|
|
|
|
<AddSourceToNuGetConfig NuGetConfigFile="$(NuGetConfigFile)"
|
|
SourceName="$(ReferencePackagesNuGetSourceName)"
|
|
SourcePath="$(ReferencePackagesDir)"
|
|
Condition="'$(DotNetBuildSourceOnly)' == 'true'" />
|
|
|
|
<AddSourceToNuGetConfig NuGetConfigFile="$(NuGetConfigFile)"
|
|
SourceName="$(SourceBuiltShippingNuGetSourceName)"
|
|
SourcePath="$(ArtifactsShippingPackagesDir)" />
|
|
|
|
<AddSourceToNuGetConfig NuGetConfigFile="$(NuGetConfigFile)"
|
|
SourceName="$(SourceBuiltNonShippingNuGetSourceName)"
|
|
SourcePath="$(ArtifactsNonShippingPackagesDir)" />
|
|
|
|
<AddSourceToNuGetConfig NuGetConfigFile="$(NuGetConfigFile)"
|
|
SourceName="$(ExtraSourcesNuGetSourceName)"
|
|
SourcePath="$(ExtraRestoreSourcePath)"
|
|
Condition="'$(ExtraRestoreSourcePath)' != ''" />
|
|
|
|
<!-- See root Directory.Build.props for value. -->
|
|
<AddSourceToNuGetConfig NuGetConfigFile="$(NuGetConfigFile)"
|
|
SourceName="$(NetSdkSupportingFeedName)"
|
|
SourcePath="$(NetSdkSupportingFeed)"
|
|
Condition="'$(AddNetSdkSupportingFeed)' == 'true'" />
|
|
|
|
<UpdateNuGetConfigPackageSourcesMappings
|
|
NuGetConfigFile="$(NuGetConfigFile)"
|
|
BuildWithOnlineFeeds="$(DotNetBuildWithOnlineFeeds)"
|
|
SourceBuildSources="$(SourceBuildSources)" />
|
|
|
|
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
|
|
<Touch Files="$(BaseIntermediateOutputPath)UpdateNuGetConfig.complete" AlwaysCreate="true">
|
|
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
|
|
</Touch>
|
|
</Target>
|
|
|
|
<!-- Update the SDK version in the repo's global.json file.
|
|
This guarantees that all repositories build with the VMR's SDK version. -->
|
|
<Target Name="UpdateGlobalJsonVersions"
|
|
Condition="'$(GlobalJsonFile)' != ''"
|
|
Inputs="$(MSBuildProjectFullPath);$(MSBuildThisFileFullPath)"
|
|
Outputs="$(BaseIntermediateOutputPath)UpdateGlobalJsonVersions.complete">
|
|
<ItemGroup>
|
|
<_PossibleCliVersionJsonPath Include="sdk:version" />
|
|
<_PossibleCliVersionJsonPath Include="tools:dotnet" />
|
|
</ItemGroup>
|
|
|
|
<UpdateJson JsonFilePath="$(GlobalJsonFile)"
|
|
PathToAttribute="%(_PossibleCliVersionJsonPath.Identity)"
|
|
NewAttributeValue="$(NETCoreSdkVersion)"
|
|
SkipUpdateIfMissingKey="true" />
|
|
|
|
<!-- VB PoC, remove the global runtimes until https://github.com/dotnet/arcade/issues/14283 is resolved. -->
|
|
<UpdateJson JsonFilePath="$(GlobalJsonFile)"
|
|
PathToAttribute="tools:runtimes"
|
|
SkipUpdateIfMissingKey="true" />
|
|
|
|
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
|
|
<Touch Files="$(BaseIntermediateOutputPath)UpdateGlobalJsonVersions.complete" AlwaysCreate="true">
|
|
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
|
|
</Touch>
|
|
</Target>
|
|
|
|
<!-- TODO: Remove when all repos use a consistent set of eng/common files: https://github.com/dotnet/source-build/issues/3710. -->
|
|
<Target Name="UpdateEngCommonFiles"
|
|
Condition="'$(UpdateEngCommonFiles)' == 'true' or '$(DotNetBuildSourceOnly)' != 'true'">
|
|
<ItemGroup>
|
|
<OrchestratorEngCommonFile Include="$(RepositoryEngineeringDir)common\**\*" />
|
|
</ItemGroup>
|
|
|
|
<Copy SourceFiles="@(OrchestratorEngCommonFile)"
|
|
DestinationFolder="$(ProjectDirectory)eng\common\%(RecursiveDir)"
|
|
SkipUnchangedFiles="true" />
|
|
</Target>
|
|
|
|
<!-- Before a repository builds, set up the version property files that override the repo's defaults.
|
|
There are 3 files generated -->
|
|
<Target Name="CreateBuildInputProps"
|
|
Inputs="$(MSBuildProjectFullPath)"
|
|
Outputs="$(BaseIntermediateOutputPath)CreateBuildInputProps.complete">
|
|
<ItemGroup>
|
|
<_CurrentSourceBuiltPackages Include="$(ArtifactsPackagesDir)**\*.nupkg"
|
|
Condition="!$([System.String]::Copy('%(Identity)').EndsWith('.symbols.nupkg'))" />
|
|
<_PreviouslyBuiltSourceBuiltPackages Include="$(PrebuiltSourceBuiltPackagesPath)*.nupkg" />
|
|
</ItemGroup>
|
|
|
|
<Error Condition="'$(PackageVersionPropsFlowType)' != 'AllPackages' and '$(PackageVersionPropsFlowType)' != 'DependenciesOnly'"
|
|
Text="Invalid PackageVersionPropsFlowType '$(PackageVersionPropsFlowType)'. Must be 'AllPackages' or 'DependenciesOnly'." />
|
|
|
|
<PropertyGroup>
|
|
<_VersionDetailsXml Condition="'$(PackageVersionPropsFlowType)' == 'DependenciesOnly'">$(ProjectDirectory)/eng/Version.Details.xml</_VersionDetailsXml>
|
|
</PropertyGroup>
|
|
|
|
<!-- Write the build input properties, then save off a copy that will be used for generating usage reports later -->
|
|
<WritePackageVersionsProps NuGetPackages="@(_CurrentSourceBuiltPackages)"
|
|
ExtraProperties="@(ExtraPackageVersionPropsPackageInfo)"
|
|
VersionPropsFlowType="$(PackageVersionPropsFlowType)"
|
|
VersionDetails="$(_VersionDetailsXml)"
|
|
OutputPath="$(CurrentSourceBuiltPackageVersionPropsPath)" />
|
|
|
|
<!-- Create previously source-built inputs info -->
|
|
<WritePackageVersionsProps NuGetPackages="@(_PreviouslyBuiltSourceBuiltPackages)"
|
|
VersionPropsFlowType="$(PackageVersionPropsFlowType)"
|
|
VersionDetails="$(_VersionDetailsXml)"
|
|
OutputPath="$(PreviouslySourceBuiltPackageVersionPropsPath)" />
|
|
|
|
<!-- Write a full package version props (unfiltered) that will be used to track which repo creates a package.
|
|
Because not all repos implement the repo API (e.g. some are external), it's difficult to consistently gather
|
|
a list of packages from the output of each repo. This may be an area for improvement later.
|
|
|
|
Instead, we rely on the package version props file that is built up
|
|
before each build. If the full list of packages grows by package A, B and C between repo Y and Z, then Y produced
|
|
A B and C.
|
|
|
|
A key element of this algorith is that we must write the full package version props and not the filtered version. -->
|
|
<WritePackageVersionsProps NuGetPackages="@(_CurrentSourceBuiltPackages)"
|
|
VersionPropsFlowType="AllPackages"
|
|
OutputPath="$(SnapshotPackageVersionPropsPath)" />
|
|
|
|
<!-- Write a single file that contains imports for both the current and previously built packages -->
|
|
<PropertyGroup>
|
|
<PackageVersionsPropsContents>
|
|
<![CDATA[
|
|
<Project>
|
|
<Import Project="$(PreviouslySourceBuiltPackageVersionPropsPath)" />
|
|
<Import Project="$(CurrentSourceBuiltPackageVersionPropsPath)" />
|
|
</Project>
|
|
]]>
|
|
</PackageVersionsPropsContents>
|
|
</PropertyGroup>
|
|
|
|
<WriteLinesToFile File="$(PackageVersionPropsPath)"
|
|
Lines="$(PackageVersionsPropsContents)"
|
|
Overwrite="true" />
|
|
|
|
<Message Importance="High" Text="$(RepositoryName) using package version properties saved at $(CurrentSourceBuiltPackageVersionPropsPath) and $(PreviouslySourceBuiltPackageVersionPropsPath)" />
|
|
|
|
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
|
|
<Touch Files="$(BaseIntermediateOutputPath)CreateBuildInputProps.complete" AlwaysCreate="true">
|
|
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
|
|
</Touch>
|
|
</Target>
|
|
|
|
<!-- SkipRepoReferences is a developer innerloop switch to skip building dependencies. -->
|
|
<Target Name="BuildRepoReferences"
|
|
Condition="'@(RepositoryReference)' != '' and '$(SkipRepoReferences)' != 'true'">
|
|
<Message Importance="High" Text="Building dependencies [@(RepositoryReference)] needed by '$(RepositoryName)'." />
|
|
|
|
<ItemGroup>
|
|
<_DependentProject Include="@(RepositoryReference -> '%(Identity).proj')" />
|
|
</ItemGroup>
|
|
|
|
<MSBuild Projects="@(_DependentProject)"
|
|
Targets="Build"
|
|
BuildInParallel="$(BuildInParallel)"
|
|
StopOnFirstFailure="true" />
|
|
</Target>
|
|
|
|
<Target Name="SetSourceBuiltSdkOverrides"
|
|
Condition="'@(SourceBuiltSdkOverride)' != ''">
|
|
<ItemGroup>
|
|
<!-- Set the environment variables for MSBuild to look for our additional SDK Resolvers and or our resolver to find our source-built SDKs. -->
|
|
<EnvironmentVariables Include="MSBUILDADDITIONALSDKRESOLVERSFOLDER=$(VSMSBuildSdkResolversDir)" />
|
|
<EnvironmentVariables Include="SOURCE_BUILT_SDK_ID_%(SourceBuiltSdkOverride.Group)=%(SourceBuiltSdkOverride.Identity)" />
|
|
<EnvironmentVariables Include="SOURCE_BUILT_SDK_VERSION_%(SourceBuiltSdkOverride.Group)=%(SourceBuiltSdkOverride.Version)" />
|
|
<EnvironmentVariables Condition="'%(SourceBuiltSdkOverride.Location)' != ''" Include="SOURCE_BUILT_SDK_DIR_%(SourceBuiltSdkOverride.Group)=%(SourceBuiltSdkOverride.Location)/" />
|
|
<EnvironmentVariables Condition="'%(SourceBuiltSdkOverride.Location)' == ''" Include="SOURCE_BUILT_SDK_DIR_%(SourceBuiltSdkOverride.Group)=$(SourceBuiltSdksDir)%(SourceBuiltSdkOverride.Identity)/" />
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<Target Name="RepoBuild"
|
|
Inputs="$(MSBuildProjectFullPath)"
|
|
Outputs="$(BaseIntermediateOutputPath)Build.complete"
|
|
Condition="'$(BuildCommand)' != ''"
|
|
DependsOnTargets="BuildRepoReferences;
|
|
UpdateNuGetConfig;
|
|
UpdateGlobalJsonVersions;
|
|
UpdateEngCommonFiles;
|
|
CreateBuildInputProps;
|
|
SetSourceBuiltSdkOverrides">
|
|
<Exec Command="$(DotnetTool) build-server shutdown" />
|
|
|
|
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Building $(RepositoryName)" />
|
|
<Message Importance="High" Text="Running command:" />
|
|
<Message Importance="High" Text=" $(BuildCommand)" />
|
|
<Message Importance="High" Text=" Log: $(RepoConsoleLogFile)" Condition="'$(MinimalConsoleLogOutput)' == 'true'" />
|
|
<Message Importance="High" Text=" With Environment Variables:"/>
|
|
<Message Importance="High" Text=" %(EnvironmentVariables.Identity)" />
|
|
|
|
<Message Text="DirSize Before Building $(RepositoryName)" Importance="High"
|
|
Condition=" '$(CleanWhileBuilding)' == 'true' and '$(BuildOS)' != 'windows'" />
|
|
<Exec Command="df -h $(RepoRoot)"
|
|
Condition=" '$(CleanWhileBuilding)' == 'true' and '$(BuildOS)' != 'windows'" />
|
|
|
|
<PropertyGroup>
|
|
<FullCommand>$(BuildCommand)</FullCommand>
|
|
<FullCommand Condition="'$(LogVerbosityOptOut)' != 'true'">$(FullCommand) /v:$(LogVerbosity)</FullCommand>
|
|
<FullCommand Condition="'$(MinimalConsoleLogOutput)' == 'true'">$(FullCommand) >> $(RepoConsoleLogFile) 2>&1</FullCommand>
|
|
</PropertyGroup>
|
|
|
|
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName('$(RepoConsoleLogFile)'));
|
|
$(ArtifactsShippingPackagesDir);
|
|
$(ArtifactsNonShippingPackagesDir);
|
|
$(ArtifactsAssetsDir)" />
|
|
|
|
<!-- Create directories for extra debugging. -->
|
|
<MakeDir Directories="$(MSBuildDebugPathTargetDir);
|
|
$(RoslynDebugPathTargetDir);
|
|
$(AspNetRazorBuildServerLogDir)"
|
|
Condition="'$(EnableExtraDebugging)' == 'true'" />
|
|
|
|
<Exec Command="$(FullCommand)"
|
|
WorkingDirectory="$(ProjectDirectory)"
|
|
EnvironmentVariables="@(EnvironmentVariables)" />
|
|
|
|
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Building $(RepositoryName)...done" />
|
|
|
|
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
|
|
<Touch Files="$(BaseIntermediateOutputPath)Build.complete" AlwaysCreate="true">
|
|
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
|
|
</Touch>
|
|
|
|
<!-- Propagate errors to the output when using the minimal console log feature. -->
|
|
<OnError ExecuteTargets="LogRepoBuildError" Condition="'$(MinimalConsoleLogOutput)' == 'true'" />
|
|
</Target>
|
|
|
|
<Target Name="LogRepoBuildError">
|
|
<Message Importance="High" Text="$([System.IO.File]::ReadAllText('$(RepoConsoleLogFile)'))" Condition="Exists('$(RepoConsoleLogFile)') and '$(MinimalConsoleLogOutput)' == 'true'" />
|
|
<Message Importance="High" Text="'$(RepositoryName)' failed during build." />
|
|
<Message Importance="High" Text="See '$(RepoConsoleLogFile)' for more information." Condition="Exists('$(RepoConsoleLogFile)') and '$(MinimalConsoleLogOutput)' == 'true'" />
|
|
</Target>
|
|
|
|
<Target Name="CopyRepoArtifacts"
|
|
DependsOnTargets="RepoBuild"
|
|
Condition="'$(IsUtilityProject)' != 'true'"
|
|
Inputs="$(RepoManifestFile)"
|
|
Outputs="$(BaseIntermediateOutputPath)CopyRepoArtifacts.complete">
|
|
<Error Text="Repo manifest file doesn't exist." Condition="!Exists('$(RepoManifestFile)')" />
|
|
|
|
<XmlPeek XmlInputPath="$(RepoManifestFile)"
|
|
Query="Build/Artifact/@Path">
|
|
<Output TaskParameter="Result" ItemName="RepoManifestArtifact" />
|
|
</XmlPeek>
|
|
|
|
<!-- Error if a repository doesn't produce any shipping or non-shipping artifacts. -->
|
|
<ItemGroup Condition="'@(RepoManifestArtifact)' == ''">
|
|
<_ArtifactsNotCreatedReason Include="^ There may have been a silent failure in the repo build." />
|
|
<_ArtifactsNotCreatedReason Include="^ To confirm, check the build log file for undetected errors that may have prevented package creation: $(RepoConsoleLogFile)" Condition="'$(MinimalConsoleLogOutput)' == 'true'" />
|
|
<_ArtifactsNotCreatedReason Include="^ The packages may have been written to an unexpected directory. For example, some repos used bin/ and changed to artifacts/ to match Arcade. Check RepoManifestFile in $(MSBuildProjectFullPath) (currently '$(RepoManifestFile)')" />
|
|
</ItemGroup>
|
|
|
|
<Error Text="$(RepositoryName) produced no new source-built package identities. Known possible causes:%0A@(_ArtifactsNotCreatedReason, '%0A')"
|
|
Condition="'@(RepoManifestArtifact)' == ''" />
|
|
|
|
<!-- The repo symbol archive shouldn't be copied. -->
|
|
<ItemGroup>
|
|
<RepoSymbolsArchive Include="@(RepoManifestArtifact)"
|
|
Condition="$([System.String]::Copy('%(Identity)').EndsWith('Symbols.$(RepositoryName)$(ArchiveExtension)'))" />
|
|
<RepoManifestArtifact Remove="@(RepoSymbolsArchive)" />
|
|
</ItemGroup>
|
|
|
|
<!-- Log the new repo artifacts -->
|
|
<Message Importance="High" Text="New artifact(s) after building $(RepositoryName):" />
|
|
<Message Importance="High" Text=" -> %(RepoManifestArtifact.Filename)%(RepoManifestArtifact.Extension)" />
|
|
|
|
<ItemGroup>
|
|
<RepoManifestPackage Include="@(RepoManifestArtifact->WithMetadataValue('Extension', '.nupkg'))" />
|
|
<RepoManifestAsset Include="@(RepoManifestArtifact)" Exclude="@(RepoManifestPackage)" />
|
|
</ItemGroup>
|
|
|
|
<!-- Prepare the repo manifest packages and group them by shipping and non-shipping. -->
|
|
<ItemGroup>
|
|
<RepoManifestNonShippingPackage Include="@(RepoManifestPackage)"
|
|
Condition="$([System.String]::Copy('%(Identity)').Contains('$([System.IO.Path]::DirectorySeparatorChar)NonShipping$([System.IO.Path]::DirectorySeparatorChar)'))">
|
|
<DestinationFolder Condition="'$(RepositoryName)' != 'source-build-reference-packages'">$(ArtifactsNonShippingPackagesDir)</DestinationFolder>
|
|
<DestinationFolder Condition="'$(RepositoryName)' == 'source-build-reference-packages'">$(ReferencePackagesDir)</DestinationFolder>
|
|
</RepoManifestNonShippingPackage>
|
|
|
|
<RepoManifestShippingPackage Include="@(RepoManifestPackage)"
|
|
Exclude="@(RepoManifestNonShippingPackage)">
|
|
<DestinationFolder Condition="'$(RepositoryName)' != 'source-build-reference-packages'">$(ArtifactsShippingPackagesDir)</DestinationFolder>
|
|
<DestinationFolder Condition="'$(RepositoryName)' == 'source-build-reference-packages'">$(ReferencePackagesDir)</DestinationFolder>
|
|
</RepoManifestShippingPackage>
|
|
</ItemGroup>
|
|
|
|
<!-- Building SBRP: At this point the References directory contains the previously-source-built SBRPs,
|
|
clear it before copying the current SBRPs. This ensures n-1 SBRPs aren't required to build the product repos. -->
|
|
<RemoveDir Directories="$(ReferencePackagesDir)"
|
|
Condition="'$(RepositoryName)' == 'source-build-reference-packages'" />
|
|
|
|
<!-- Copy shipping packages -->
|
|
<Copy SourceFiles="@(RepoManifestShippingPackage)"
|
|
DestinationFolder="%(RepoManifestShippingPackage.DestinationFolder)"
|
|
Condition="'@(RepoManifestShippingPackage)' != ''" />
|
|
|
|
<!-- Copy non-shipping packages -->
|
|
<Copy SourceFiles="@(RepoManifestNonShippingPackage)"
|
|
DestinationFolder="%(RepoManifestNonShippingPackage.DestinationFolder)"
|
|
Condition="'@(RepoManifestNonShippingPackage)' != ''" />
|
|
|
|
<!-- Copy assets -->
|
|
<Copy SourceFiles="@(RepoManifestAsset)"
|
|
DestinationFolder="$(ArtifactsAssetsDir)"
|
|
Condition="'@(RepoManifestAsset)' != ''" />
|
|
|
|
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
|
|
<Touch Files="$(BaseIntermediateOutputPath)CopyRepoArtifacts.complete" AlwaysCreate="true">
|
|
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
|
|
</Touch>
|
|
</Target>
|
|
|
|
<!-- Copy restored packages from inner build to ensure they're included in the
|
|
main build prebuilt check -->
|
|
<Target Name="CopyInnerBuildRestoredPackages"
|
|
Condition="'$(IsUtilityProject)' != 'true'">
|
|
<ItemGroup>
|
|
<_InnerPackageCacheFiles Include="$(ProjectDirectory)artifacts/sb/package-cache/**/*" />
|
|
</ItemGroup>
|
|
|
|
<Copy SourceFiles="@(_InnerPackageCacheFiles)"
|
|
DestinationFiles="$(NuGetPackageRoot)%(RecursiveDir)%(Filename)%(Extension)"
|
|
SkipUnchangedFiles="true"
|
|
Condition="'@(_InnerPackageCacheFiles)' != ''" />
|
|
</Target>
|
|
|
|
<Target Name="CleanupRepo"
|
|
Condition="'$(IsUtilityProject)' != 'true' and
|
|
'$(CleanWhileBuilding)' == 'true' and
|
|
Exists('$(ProjectDirectory)artifacts')">
|
|
<!--
|
|
Some repositories (WinForms) use source generators that open files manually and keep file handles open on the compiler server (CsWin32).
|
|
These source generators are written incorrectly (a source generator should never do IO itself),
|
|
but the required features to read in binary files as input to a source generator don't exist.
|
|
To work around these source generators, shut down the compiler server so we can delete the obj directories.
|
|
-->
|
|
<Exec Command="$(DotnetTool) build-server shutdown --vbcscompiler" />
|
|
|
|
<PropertyGroup>
|
|
<BuildLogsDir>$([MSBuild]::NormalizeDirectory('$(ProjectDirectory)', 'artifacts', 'buildLogs'))</BuildLogsDir>
|
|
<BuildObjDir>$([MSBuild]::NormalizeDirectory('$(ProjectDirectory)', 'artifacts', 'buildObj'))</BuildObjDir>
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup>
|
|
<LogFilesToCopy Include="$(ProjectDirectory)artifacts/**/*.log" />
|
|
<LogFilesToCopy Include="$(ProjectDirectory)artifacts/**/*.binlog" />
|
|
<ObjFilesToCopy Include="$(ProjectDirectory)artifacts/**/project.assets.json" />
|
|
</ItemGroup>
|
|
|
|
<!-- Make a copy of the build logs & project.assets.json files -->
|
|
<Copy SourceFiles="@(LogFilesToCopy)"
|
|
DestinationFolder="$(BuildLogsDir)%(RecursiveDir)"
|
|
SkipUnchangedFiles="true"
|
|
Condition="'@(LogFilesToCopy)' != ''" />
|
|
<Copy SourceFiles="@(ObjFilesToCopy)"
|
|
DestinationFolder="$(BuildObjDir)%(RecursiveDir)"
|
|
SkipUnchangedFiles="true"
|
|
Condition="'@(ObjFilesToCopy)' != ''" />
|
|
|
|
<ItemGroup>
|
|
<DirsToDelete Include="$([System.IO.Directory]::GetDirectories('$(ProjectDirectory)artifacts'))" />
|
|
|
|
<DirsToDeleteWithTrailingSeparator Include="$([MSBuild]::EnsureTrailingSlash('%(DirsToDelete.Identity)'))" />
|
|
<DirsToDeleteWithTrailingSeparator Remove="$(BuildLogsDir)" />
|
|
<DirsToDeleteWithTrailingSeparator Remove="$(BuildObjDir)" />
|
|
</ItemGroup>
|
|
|
|
<Message Text="DirSize After Building $(RepositoryName)" Importance="High" Condition="'$(BuildOS)' != 'windows' and '@(DirsToDeleteWithTrailingSeparator)' != ''" />
|
|
<Exec Command="df -h $(RepoRoot)" Condition="'$(BuildOS)' != 'windows' and '@(DirsToDeleteWithTrailingSeparator)' != ''" />
|
|
|
|
<!-- Cleanup everything else -->
|
|
<RemoveDir Directories="@(DirsToDeleteWithTrailingSeparator)" />
|
|
|
|
<Message Text="DirSize After CleanupRepo $(RepositoryName)" Importance="High" Condition="'$(BuildOS)' != 'windows'and '@(DirsToDeleteWithTrailingSeparator)' != ''" />
|
|
<Exec Command="df -h $(RepoRoot)" Condition="'$(BuildOS)' != 'windows'and '@(DirsToDeleteWithTrailingSeparator)' != ''" />
|
|
</Target>
|
|
|
|
<Target Name="ExtractToolPackage"
|
|
DependsOnTargets="CopyRepoArtifacts"
|
|
Condition="'@(BuiltSdkPackageOverride)' != ''"
|
|
Inputs="$(MSBuildProjectFullPath)"
|
|
Outputs="$(BaseIntermediateOutputPath)ExtractToolPackage.complete">
|
|
<PropertyGroup>
|
|
<_ToolPackagesRoot Condition="'$(RepositoryName)' != 'source-build-reference-packages'">$(ArtifactsNonShippingPackagesDir)</_ToolPackagesRoot>
|
|
<_ToolPackagesRoot Condition="'$(RepositoryName)' == 'source-build-reference-packages'">$(ReferencePackagesDir)</_ToolPackagesRoot>
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup>
|
|
<_ToolPackage
|
|
Condition="'%(BuiltSdkPackageOverride.Version)' == ''"
|
|
Include="$(_ToolPackagesRoot)%(BuiltSdkPackageOverride.Identity)*.nupkg"
|
|
Exclude="$(_ToolPackagesRoot)%(BuiltSdkPackageOverride.Identity)*.symbols.nupkg"
|
|
Id="%(BuiltSdkPackageOverride.Identity)" />
|
|
<_ToolPackage
|
|
Condition="'%(BuiltSdkPackageOverride.Version)' != ''"
|
|
Include="$(_ToolPackagesRoot)%(BuiltSdkPackageOverride.Identity).%(BuiltSdkPackageOverride.Version).nupkg"
|
|
Exclude="$(_ToolPackagesRoot)%(BuiltSdkPackageOverride.Identity).%(BuiltSdkPackageOverride.Version).symbols.nupkg"
|
|
Id="%(BuiltSdkPackageOverride.Identity)" />
|
|
</ItemGroup>
|
|
|
|
<Unzip SourceFiles="%(_ToolPackage.Identity)"
|
|
DestinationFolder="$(SourceBuiltSdksDir)%(_ToolPackage.Id)\"
|
|
SkipUnchangedFiles="true" />
|
|
|
|
<ItemGroup>
|
|
<ExtractedToolFiles Include="$(SourceBuiltSdksDir)%(_ToolPackage.Id)/**/*netcore*/*.dll" />
|
|
</ItemGroup>
|
|
|
|
<Copy SourceFiles="@(ExtractedToolFiles)" DestinationFolder="$(SourceBuiltSdksDir)/" />
|
|
|
|
<!-- When unpacking, this executable file has the wrong permissions on
|
|
non-windows systems: https://github.com/NuGet/Home/issues/13121. -->
|
|
<Exec Command="chmod 755 git-clone-to-dir.sh"
|
|
Condition=" '%(_ToolPackage.Id)' == 'Microsoft.DotNet.Arcade.Sdk' and !$([MSBuild]::IsOSPlatform(Windows))"
|
|
WorkingDirectory="$(SourceBuiltSdksDir)%(_ToolPackage.Id)/tools/SourceBuild/" />
|
|
|
|
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
|
|
<Touch Files="$(BaseIntermediateOutputPath)ExtractToolPackage.complete" AlwaysCreate="true">
|
|
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
|
|
</Touch>
|
|
</Target>
|
|
|
|
<Target Name="ExtractSymbolsArchiveFile"
|
|
DependsOnTargets="CopyRepoArtifacts"
|
|
Condition="'$(DotNetBuildSourceOnly)' == 'true' and
|
|
'$(IsUtilityProject)' != 'true' and
|
|
'@(RepoSymbolsArchive)' != ''"
|
|
Inputs="@(RepoSymbolsArchive)"
|
|
Outputs="$(IntermediateSymbolsRepoDir)">
|
|
|
|
<Error Text="There must only be a single repository symbols archive file. Found: @(RepoSymbolsArchive)"
|
|
Condition="@(RepoSymbolsArchive->Count()) > 1" />
|
|
|
|
<!-- Extract repo symbols tarball -->
|
|
<MakeDir Directories="$(IntermediateSymbolsRepoDir)" />
|
|
<Exec Command="tar -xzf %(RepoSymbolsArchive.Identity) -C $(IntermediateSymbolsRepoDir)" />
|
|
</Target>
|
|
|
|
<Target Name="Build"
|
|
DependsOnTargets="
|
|
BuildRepoReferences;
|
|
RepoBuild;
|
|
CopyRepoArtifacts;
|
|
CopyInnerBuildRestoredPackages;
|
|
ExtractToolPackage;
|
|
ExtractSymbolsArchiveFile;
|
|
CleanupRepo" />
|
|
|
|
<Target Name="WritePrebuiltUsageData"
|
|
DependsOnTargets="GetAllProjectDirectories"
|
|
Inputs="$(MSBuildProjectFullPath)"
|
|
Outputs="$(BaseIntermediateOutputPath)WritePrebuiltUsageData.complete">
|
|
<!-- Save the PVP snapshot of each build step to be evaluated while building the report. -->
|
|
<ItemGroup>
|
|
<PackageVersionPropsSnapshotFiles Include="$(PackageVersionsDir)PackageVersions.*.Snapshot.props" />
|
|
</ItemGroup>
|
|
<Copy SourceFiles="@(PackageVersionPropsSnapshotFiles)" DestinationFolder="$(PackageReportDir)snapshots/" />
|
|
|
|
<ItemGroup>
|
|
<AllRestoredPackageFiles Include="$(NuGetPackageRoot)**/*.nupkg" />
|
|
|
|
<!-- Only contains packages when building. -->
|
|
<TarballPrebuiltPackageFiles Include="$(PrebuiltPackagesPath)*.nupkg" />
|
|
|
|
<SourceBuiltPackageFiles Include="$(ArtifactsPackagesDir)**/*.nupkg" />
|
|
<SourceBuiltPackageFiles Include="$(PrebuiltSourceBuiltPackagesPath)*.nupkg" />
|
|
<ReferencePackageFiles Include="$(ReferencePackagesDir)**/*.nupkg" />
|
|
|
|
<!-- Check all RIDs from all restored Microsoft.NETCore.Platforms packages. -->
|
|
<PlatformsRuntimeJsonFiles Include="$(NuGetPackageRoot)microsoft.netcore.platforms/*/PortableRuntimeIdentifierGraph.json" />
|
|
|
|
<!-- Add some other potential top-level project directories for a more specific report. -->
|
|
<ProjectDirectories Include="$(SourceBuiltSdksDir);$(TasksDir);$(ArtifactsObjDir)" />
|
|
<!-- Finally, scan entire source-build, in case project.assets.json ends up in an unexpected place. -->
|
|
<ProjectDirectories Include="$(RepoRoot)" />
|
|
</ItemGroup>
|
|
|
|
<ItemGroup>
|
|
<!-- This file is a resource tracked by Git, not generated by restore. Ignore false positive. -->
|
|
<IgnoredProjectAssetsJsonFiles Include="$(SrcDir)*nuget-client*/**/test/NuGet.Core.Tests/NuGet.Build.Tasks.Pack.Test/compiler/resources/project.assets.json"/>
|
|
</ItemGroup>
|
|
|
|
<WritePackageUsageData
|
|
RestoredPackageFiles="@(AllRestoredPackageFiles)"
|
|
TarballPrebuiltPackageFiles="@(TarballPrebuiltPackageFiles)"
|
|
SourceBuiltPackageFiles="@(SourceBuiltPackageFiles)"
|
|
ReferencePackageFiles="@(ReferencePackageFiles)"
|
|
PlatformsRuntimeJsonFiles="@(PlatformsRuntimeJsonFiles)"
|
|
TargetRid="$(TargetRid)"
|
|
ProjectDirectories="@(ProjectDirectories)"
|
|
RootDir="$(RepoRoot)"
|
|
IgnoredProjectAssetsJsonFiles="@(IgnoredProjectAssetsJsonFiles)"
|
|
DataFile="$(PackageReportDataFile)"
|
|
ProjectAssetsJsonArchiveFile="$(ProjectAssetsJsonArchiveFile)" />
|
|
|
|
<!-- Copy packages detected as prebuilts to the artifacts prebuilt folder -->
|
|
<ItemGroup>
|
|
<AllowedPackageFiles Include="@(TarballPrebuiltPackageFile)" />
|
|
<AllowedPackageFiles Include="@(SourceBuiltPackageFiles)" />
|
|
<AllowedPackageFiles Include="@(ReferencePackageFiles)" />
|
|
<AllowedPackageFiles>
|
|
<LCFilename>$([System.String]::Copy(%(Filename)).ToLowerInvariant())</LCFilename>
|
|
</AllowedPackageFiles>
|
|
|
|
<PrebuiltPackageFiles Include="@(AllRestoredPackageFiles)" >
|
|
<LCFilename>$([System.String]::Copy(%(Filename)).ToLowerInvariant())</LCFilename>
|
|
</PrebuiltPackageFiles>
|
|
<PrebuiltPackageFiles Remove="@(AllowedPackageFiles)" MatchOnMetadata="LCFilename" />
|
|
</ItemGroup>
|
|
<Copy
|
|
SourceFiles="@(PrebuiltPackageFiles)"
|
|
DestinationFolder="$(ResultingPrebuiltPackagesDir)" />
|
|
|
|
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
|
|
<Touch Files="$(BaseIntermediateOutputPath)WritePrebuiltUsageData.complete" AlwaysCreate="true">
|
|
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
|
|
</Touch>
|
|
</Target>
|
|
|
|
<Target Name="GetAllProjectDirectories">
|
|
<ItemGroup>
|
|
<AllRepoProjects Include="$(RepoProjectsDir)*.proj" />
|
|
</ItemGroup>
|
|
|
|
<Message Importance="High" Text="Finding project directories..." />
|
|
|
|
<MSBuild Projects="@(AllRepoProjects)"
|
|
Targets="GetProjectDirectory">
|
|
<Output TaskParameter="TargetOutputs" ItemName="ProjectDirectories" />
|
|
</MSBuild>
|
|
</Target>
|
|
|
|
<Target Name="ReportPrebuiltUsage"
|
|
Inputs="$(MSBuildProjectFullPath)"
|
|
Outputs="$(BaseIntermediateOutputPath)ReportPrebuiltUsage.complete">
|
|
<PropertyGroup>
|
|
<FailOnPrebuiltBaselineError Condition="'$(FailOnPrebuiltBaselineError)' == ''">false</FailOnPrebuiltBaselineError>
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup>
|
|
<PackageVersionPropsSavedSnapshotFiles Include="$(PackageReportDir)snapshots/PackageVersions.*.Snapshot.props" />
|
|
</ItemGroup>
|
|
|
|
<WriteUsageReports DataFile="$(PackageReportDataFile)"
|
|
PackageVersionPropsSnapshots="@(PackageVersionPropsSavedSnapshotFiles)"
|
|
ProdConBuildManifestFile="$(ProdConManifestFile)"
|
|
PoisonedReportFile="$(PoisonedReportFile)"
|
|
OutputDirectory="$(PackageReportDir)" />
|
|
|
|
<PropertyGroup Condition="'$(ContinueOnPrebuiltBaselineError)' == ''">
|
|
<ContinueOnPrebuiltBaselineError>false</ContinueOnPrebuiltBaselineError>
|
|
<ContinueOnPrebuiltBaselineError Condition="'$(FailOnPrebuiltBaselineError)' != 'true'">true</ContinueOnPrebuiltBaselineError>
|
|
</PropertyGroup>
|
|
|
|
<ValidateUsageAgainstBaseline
|
|
DataFile="$(PackageReportDataFile)"
|
|
BaselineDataFile="$(BaselineDataFile)"
|
|
OutputBaselineFile="$(PackageReportDir)generated-new-baseline.xml"
|
|
OutputReportFile="$(PackageReportDir)baseline-comparison.xml"
|
|
AllowTestProjectUsage="$(AllowTestProjectUsage)"
|
|
ContinueOnError="$(ContinueOnPrebuiltBaselineError)" />
|
|
|
|
<MakeDir Directories="$(BaseIntermediateOutputPath)" />
|
|
<Touch Files="$(BaseIntermediateOutputPath)ReportPrebuiltUsage.complete" AlwaysCreate="true">
|
|
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
|
|
</Touch>
|
|
</Target>
|
|
|
|
<Target Name="GetProjectDirectory" Outputs="$(ProjectDirectory)" />
|
|
<Target Name="GetRepositoryReferences" Outputs="@(RepositoryReference)" />
|
|
|
|
</Project>
|