Explorar o código

Ensure trx logging is reported correctly when building in TeamCity

Nate McMaster %!s(int64=7) %!d(string=hai) anos
pai
achega
62ea0264e4
Modificáronse 2 ficheiros con 13 adicións e 5 borrados
  1. 11 4
      build/SharedFx.targets
  2. 2 1
      dockerbuild.sh

+ 11 - 4
build/SharedFx.targets

@@ -530,9 +530,17 @@
 
   <Target Name="BuildSharedFx" DependsOnTargets="GeneratePropsFiles;ResolveSharedFxFiles;CrossGenAssemblies;CrossGenSymbols;PackSharedFx;TestSharedFx"/>
 
+
   <Target Name="TestSharedFx" DependsOnTargets="GeneratePropsFiles;DefineSharedFxPrerequisites;ResolveCommitHash;InstallDotNet">
     <PropertyGroup>
       <UnitTestFxProject>$(RepositoryRoot)\test\SharedFx.UnitTests\SharedFx.UnitTests.csproj</UnitTestFxProject>
+
+      <!-- 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>
+
       <UnitTestFxTestProps>
         DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath);
         DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath);
@@ -540,7 +548,6 @@
         RepositoryCommit=$(RepositoryCommit);
         SharedFxRuntimeIdentifier=$(SharedFXRid)
       </UnitTestFxTestProps>
-      <TrxFile>$(LogOutputDir)SharedFx.UnitTests-$(BuildNumber).trx</TrxFile>
     </PropertyGroup>
     <MSBuild Projects="$(UnitTestFxProject)" Targets="Restore" Properties="_Dummy=restore;$(UnitTestFxTestProps)" />
     <MSBuild Projects="$(UnitTestFxProject)" Targets="Build" Properties="$(UnitTestFxTestProps)">
@@ -548,15 +555,15 @@
     </MSBuild>
     <RunDotNet Arguments="vstest;
       --Framework:%(TargetFrameworkIdentifier),Version=v%(TargetFrameworkVersion);
-      --Logger:$([MSBuild]::Escape('trx;LogFileName=$(TrxFile)'));
+      --Logger:$([MSBuild]::Escape('trx;LogFileName=$(UnitTestFxTrxLogFile)'));
       %(SharedFxTestAssembly.Identity);
       --;RunConfiguration.NoAutoReporters=true" IgnoreExitCode="true">
       <Output TaskParameter="ExitCode" PropertyName="VsTestExitCode" />
     </RunDotNet>
 
-    <Message Text="##teamcity[importData type='vstest' path='$(TrxFile)']"
+    <Message Text="##teamcity[importData type='vstest' path='$(UnitTestFxTrxPhysicalFilePath)']"
       Importance="High"
-      Condition="'$(TEAMCITY_VERSION)' != '' AND Exists($(TrxFile))" />
+      Condition="'$(TEAMCITY_VERSION)' != '' AND Exists('$(UnitTestFxTrxLogFile)')" />
     <Error Text="SharedFx.UnitTests failed with exit code '$(VsTestExitCode)'." Condition=" $(VsTestExitCode) != 0 " />
   </Target>
 

+ 2 - 1
dockerbuild.sh

@@ -108,4 +108,5 @@ docker run \
     ${docker_args[@]+"${docker_args[@]}"} \
     $tagname \
     ./build.sh \
-    ${build_args[@]+"${build_args[@]}"}
+    ${build_args[@]+"${build_args[@]}"} \
+    "-p:HostMachineRepositoryRoot=$DIR"