| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <Project>
- <!--
- Test asset publication support intended for case where an asset is referenced in a single test project.
- References in more than one or two test projects would slow the build because each restore or publish
- operation gets unique (per-test project) global properties.
- Hook into Build target in addition to Publish (for Helix), RunTests (for Arcade), and VSTest (for dotnet test)
- because VS does not use a target when discovering or executing tests (examines test assembly instead). Need
- those targets too to ensure everything is up-to-date when executing tests.
- -->
- <Target Name="PublishTestAssets"
- BeforeTargets="Build;Publish;RunTests;VSTest"
- Condition=" '$(ExcludeFromBuild)' != 'true' AND
- '$(DotNetBuildFromSource)' != 'true' AND
- '@(TestAssetProjectReference->Count())' != '0' ">
- <ItemGroup>
- <_ProjectsToPublish Include="@(TestAssetProjectReference)" />
- <!-- Always Publish test assets relative to test project's output. -->
- <_ProjectsToPublish AdditionalProperties="%(_ProjectsToPublish.AdditionalProperties);
- PublishDir=$(PublishDir)%(RelativeFolder)" />
- <!-- Do not build when publishing if SkipBuild requested. -->
- <_ProjectsToPublish Condition=" '%(SkipBuild)' == 'true' "
- AdditionalProperties="%(_ProjectsToPublish.AdditionalProperties);NoBuild=true" />
- <!--
- Otherwise, both Build and Publish test assets into folders relative to test project's output. Reset
- NoBuild because these projects aren't referenced anywhere else.
- -->
- <_ProjectsToPublish Condition=" '%(SkipBuild)' != 'true' "
- AdditionalProperties="%(_ProjectsToPublish.AdditionalProperties);
- NoBuild=false;
- OutputPath=$(OutputPath)%(RelativeFolder)" />
- </ItemGroup>
- <!--
- These are separate invocations to ensure Publish sees restored setup. Platform and PlatformTarget removals
- are to fix builds inside VS.
- -->
- <MSBuild Projects="@(_ProjectsToPublish->WithMetadataValue('SkipBuild', 'false'))"
- BuildInParallel="$(BuildInParallel)"
- Properties="MSBuildRestoreSessionId=$([System.Guid]::NewGuid())"
- RemoveProperties="Platform;PlatformTarget"
- Targets="Restore" />
- <MSBuild Projects="@(_ProjectsToPublish)" Targets="Publish" RemoveProperties="Platform;PlatformTarget" />
- </Target>
- </Project>
|