aspnetcore/build/SharedFx.targets

99 lines
5.4 KiB
XML

<Project>
<PropertyGroup>
<UnitTestFxProject>$(RepositoryRoot)src\Framework\Framework.UnitTests\Framework.UnitTests.csproj</UnitTestFxProject>
<UnitTestFxProject>$([MSBuild]::NormalizePath($(UnitTestFxProject)))</UnitTestFxProject>
<CodeSignDependsOn>$(CodeSignDependsOn);GetSharedFxFilesToSign</CodeSignDependsOn>
<BuildSharedFxDependsOn>_BuildSharedFxProjects;TestSharedFx</BuildSharedFxDependsOn>
<BuildSharedFxDependsOn Condition="'$(TestOnly)' != 'true'">$(BuildSharedFxDependsOn);CodeSign</BuildSharedFxDependsOn>
<RedistNetCorePath>$(IntermediateDir)ar\$(SharedFxRid)\</RedistNetCorePath>
</PropertyGroup>
<ItemGroup>
<ProjectToBuild Include="$(RepositoryRoot)src\Framework\**\*.pkgproj" />
<ProjectToBuild Include="$(RepositoryRoot)src\Framework\**\*.shfxproj" />
<ProjectToBuild Include="$(UnitTestFxProject)" />
<ProjectToBuild Condition=" '$(BuildRuntimeArchive)' != 'false' " Include="$(RepositoryRoot)src\Installers\Archive\*.*proj" />
<ProjectToBuild Condition=" '$(SharedFxRid)' == 'linux-x64' AND '$(LinuxInstallerType)' == 'deb' " Include="$(RepositoryRoot)src\Installers\Debian\*.*proj" />
<ProjectToBuild Condition=" '$(SharedFxRid)' == 'linux-x64' AND '$(LinuxInstallerType)' == 'rpm' " Include="$(RepositoryRoot)src\Installers\Rpm\*.*proj" />
</ItemGroup>
<Target Name="BuildSharedFx" DependsOnTargets="$(BuildSharedFxDependsOn)" />
<Target Name="GetSharedFxFilesToSign">
<ItemGroup>
<FilesToSign Include="$(ArtifactsDir)$(Configuration)\installers\aspnetcore-runtime-$(PackageVersion)-$(SharedFxRid).zip" Certificate="None" />
<FilesToSign Include="$(ArtifactsDir)$(Configuration)\installers\aspnetcore-runtime-internal-$(PackageVersion)-$(SharedFxRid).zip" Certificate="None" />
<FilesToSign Include="$(BuildDir)Microsoft.AspNetCore.App.$(PackageVersion).nupkg" Certificate="$(PackageSigningCertName)" />
<FilesToSign Include="$(BuildDir)runtime.$(SharedFxRid).Microsoft.AspNetCore.App.$(PackageVersion).nupkg" Certificate="$(PackageSigningCertName)" />
<FilesToSign Include="$(BuildDir)runtime.$(SharedFxRid).Microsoft.AspNetCore.App.$(PackageVersion).symbols.nupkg" Certificate="$(PackageSigningCertName)" />
</ItemGroup>
<!-- These files should already be signed by the .NET Core team. They have to be listed again here because we recreate a redistributable which includes the Microsoft.NETCore.App runtime. -->
<ItemGroup>
<FilesToExcludeFromSigning Include="$(RedistNetCorePath)shared\Microsoft.NETCore.App\**\*.dll" />
<FilesToExcludeFromSigning Include="$(RedistNetCorePath)host\**\*.dll" />
<FilesToExcludeFromSigning Include="$(RedistNetCorePath)dotnet.exe" />
</ItemGroup>
</Target>
<Target Name="_BuildSharedFxProjects" DependsOnTargets="GeneratePropsFiles;ResolveCommitHash">
<PropertyGroup>
<_RestoreGraphProjectInput>@(ProjectToBuild)</_RestoreGraphProjectInput>
<SharedFxBuildProperties>
$(BuildProperties);
SharedFxRid=$(SharedFxRid);
DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath);
DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath)
</SharedFxBuildProperties>
</PropertyGroup>
<MSBuild Projects="$(MSBuildToolsPath)\NuGet.targets"
Targets="Restore"
Properties="$(SharedFxBuildProperties);RestoreGraphProjectInput=$(_RestoreGraphProjectInput);_DummyTarget=Restore" />
<MSBuild Projects="@(ProjectToBuild)"
Properties="$(SharedFxBuildProperties)"
BuildInParallel="true" />
<MSBuild Projects="@(ProjectToBuild)"
Targets="Pack"
Properties="$(SharedFxBuildProperties);NoBuild=true"
BuildInParallel="true"
SkipNonexistentTargets="true" />
</Target>
<Target Name="TestSharedFx" DependsOnTargets="GeneratePropsFiles;InstallDotNet">
<PropertyGroup>
<!-- The file path to the log file, from within the container -->
<UnitTestFxTrxLogFile>$(LogOutputDir)SharedFx-UnitTests-$(Version).trx</UnitTestFxTrxLogFile>
<!-- The trx file path from the perspective of the TeamCity agent -->
<UnitTestFxTrxPhysicalFilePath>$(UnitTestFxTrxLogFile)</UnitTestFxTrxPhysicalFilePath>
<UnitTestFxTrxPhysicalFilePath Condition="'$(HostMachineRepositoryRoot)' != ''">$(HostMachineRepositoryRoot)/artifacts/logs/SharedFx-UnitTests.trx</UnitTestFxTrxPhysicalFilePath>
</PropertyGroup>
<MSBuild Projects="$(UnitTestFxProject)" Targets="GetTargetPath" Properties="$(BuildProperties)">
<Output TaskParameter="TargetOutputs" ItemName="SharedFxTestAssembly" />
</MSBuild>
<RunDotNet
IgnoreStandardErrorWarningFormat="true"
IgnoreExitCode="true"
Arguments="vstest;
--Framework:%(TargetFrameworkIdentifier),Version=v%(TargetFrameworkVersion);
--Logger:$([MSBuild]::Escape('trx;LogFileName=$(UnitTestFxTrxLogFile)'));
%(SharedFxTestAssembly.Identity);
--;RunConfiguration.NoAutoReporters=true">
<Output TaskParameter="ExitCode" PropertyName="VsTestExitCode" />
</RunDotNet>
<Message Text="##teamcity[importData type='vstest' path='$(UnitTestFxTrxPhysicalFilePath)']"
Importance="High"
Condition="'$(TEAMCITY_VERSION)' != '' AND Exists('$(UnitTestFxTrxLogFile)')" />
<Error Text="SharedFx.UnitTests failed with exit code '$(VsTestExitCode)'." Condition=" $(VsTestExitCode) != 0 " />
</Target>
</Project>