aspnetcore/build/SharedFx.targets

78 lines
3.5 KiB
XML

<Project>
<Import Project="SharedFx.props" />
<PropertyGroup>
<UnitTestFxProject>$(RepositoryRoot)src\Framework\Framework.UnitTests\Framework.UnitTests.csproj</UnitTestFxProject>
<UnitTestFxProject>$([MSBuild]::NormalizePath($(UnitTestFxProject)))</UnitTestFxProject>
</PropertyGroup>
<ItemGroup>
<ProjectToBuild Include="$(RepositoryRoot)src\Framework\**\*.pkgproj" />
<ProjectToBuild Include="$(RepositoryRoot)src\Framework\**\*.shfxproj" />
<ProjectToBuild Include="$(UnitTestFxProject)" />
<ProjectToBuild Include="$(RepositoryRoot)src\Installers\Archive.Internal\*.*proj" />
<ProjectToBuild Include="$(RepositoryRoot)src\Installers\Archive.Redist\*.*proj" />
</ItemGroup>
<Target Name="BuildSharedFx" DependsOnTargets="_BuildSharedFxProjects;TestSharedFx"/>
<Target Name="_BuildSharedFxProjects" DependsOnTargets="GeneratePropsFiles;ResolveCommitHash">
<PropertyGroup>
<_RestoreGraphProjectInput>@(ProjectToBuild)</_RestoreGraphProjectInput>
<SharedFxBuildProperties>
$(SolutionProperties);
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="$(SolutionProperties)">
<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>