File tree Expand file tree Collapse file tree 5 files changed +51
-21
lines changed 
Tasks/Microsoft.NET.Build.Tasks/targets 
Tests/Microsoft.NET.Clean.Tests Expand file tree Collapse file tree 5 files changed +51
-21
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,9 @@ function InitializeDotNetCli {
9292    $env: DOTNET_INSTALL_DIR  =  $env: DotNetCoreSdkDir     
9393  }
9494
95+   #  Save MSBuild crash files info to log directory so that they are captured as build artifacts
96+   $env: MSBUILDDEBUGPATH = $LogDir 
97+ 
9598  #  Use dotnet installation specified in DOTNET_INSTALL_DIR if it contains the required SDK version, 
9699  #  otherwise install the dotnet CLI and SDK to repo local .dotnet directory to avoid potential permission issues.
97100  if  (($env: DOTNET_INSTALL_DIR  -ne  $null ) -and  (Test-Path (Join-Path  $env: DOTNET_INSTALL_DIR  " sdk\$ ( $GlobalJson.sdk.version  ) " 
Original file line number Diff line number Diff line change @@ -167,6 +167,9 @@ function InitializeDotNetCli {
167167    export  DOTNET_INSTALL_DIR=" $DotNetCoreSdkDir " 
168168  fi 
169169
170+   #  Save MSBuild crash files info to log directory so that they are captured as build artifacts
171+   export  MSBUILDDEBUGPATH=" $log_dir " 
172+ 
170173  ReadJson " $global_json_file " " version" 
171174  local  dotnet_sdk_version=" $readjsonvalue " 
172175  local  dotnet_root=" " 
Original file line number Diff line number Diff line change @@ -92,14 +92,14 @@ Copyright (c) .NET Foundation. All rights reserved.
9292
9393  <PropertyGroup >
9494    <CoreCleanDependsOn >
95-       SuppressAssetsLogMessages; 
95+       _SdkBeforeClean 
9696      $(CoreCleanDependsOn)
9797    </CoreCleanDependsOn >
9898  </PropertyGroup >
9999
100100  <PropertyGroup >
101101    <RebuildDependsOn >
102-       UnsuppressAssetsLogMessages ;
102+       _SdkBeforeRebuild ;
103103      $(RebuildDependsOn)
104104    </RebuildDependsOn >
105105  </PropertyGroup >
@@ -200,29 +200,16 @@ Copyright (c) .NET Foundation. All rights reserved.
200200    </ItemGroup >
201201  </Target >
202202
203-   <!-- 
204-     ============================================================ 
205-                                         SuppressAssetsLogMessages 
206- 
207-     Suppresses log messages from an existing project assets file. 
208-     ============================================================ 
209-     -->  
210-   <Target  Name =" SuppressAssetsLogMessages" Condition =" '$(UnsuppressAssetsLogMessages)' != 'true'" 
211-     <PropertyGroup >
203+   <Target  Name =" _SdkBeforeClean" 
204+     <PropertyGroup  Condition =" '$(_CleaningWithoutRebuilding)' == ''" 
205+       <_CleaningWithoutRebuilding >true</_CleaningWithoutRebuilding >
212206      <EmitAssetsLogMessages >false</EmitAssetsLogMessages >
213207    </PropertyGroup >
214208  </Target >
215209
216-   <!-- 
217-     ============================================================ 
218-                                         UnsuppressAssetsLogMessages 
219- 
220-     Unsuppresses log messages from an existing project assets file. 
221-     ============================================================ 
222-     -->  
223-   <Target  Name =" UnsuppressAssetsLogMessages" 
210+   <Target  Name =" _SdkBeforeRebuild" 
224211    <PropertyGroup >
225-       <UnsuppressAssetsLogMessages >true</ UnsuppressAssetsLogMessages >
212+       <_CleaningWithoutRebuilding >false</ _CleaningWithoutRebuilding >
226213    </PropertyGroup >
227214  </Target >
228215
Original file line number Diff line number Diff line change @@ -126,7 +126,8 @@ Copyright (c) .NET Foundation. All rights reserved.
126126    </ResolvePackageDependenciesForBuildDependsOn >
127127  </PropertyGroup >
128128  <Target  Name =" ResolvePackageDependenciesForBuild" 
129-           Condition ="  '$(DesignTimeBuild)' != 'true' Or Exists('$(ProjectAssetsFile)')" 
129+           Condition ="  ('$(DesignTimeBuild)' != 'true' and '$(_CleaningWithoutRebuilding)' != 'true')
130+                       Or Exists('$(ProjectAssetsFile)')"  
130131          BeforeTargets =" AssignProjectConfiguration" 
131132          DependsOnTargets =" $(ResolvePackageDependenciesForBuildDependsOn)" 
132133
Original file line number Diff line number Diff line change @@ -53,5 +53,41 @@ public void It_cleans_without_logging_assets_message()
5353                . And 
5454                . NotHaveStdOutContaining ( "warning" ) ; 
5555        } 
56+ 
57+         [ Fact ] 
58+         public  void  It_cleans_without_assets_file_present ( ) 
59+         { 
60+             var  testAsset  =  _testAssetsManager 
61+                 . CopyTestAsset ( "HelloWorld" ) 
62+                 . WithSource ( ) ; 
63+ 
64+             var  assetsFilePath  =  Path . Combine ( testAsset . TestRoot ,  "obj" ,  "project.assets.json" ) ; 
65+             File . Exists ( assetsFilePath ) . Should ( ) . BeFalse ( ) ; 
66+ 
67+             var  cleanCommand  =  new  CleanCommand ( Log ,  testAsset . TestRoot ) ; 
68+ 
69+             cleanCommand 
70+                 . Execute ( ) 
71+                 . Should ( ) 
72+                 . Pass ( ) ; 
73+         } 
74+ 
75+         // Related to https://github.com/dotnet/sdk/issues/2233 
76+         // This test will fail if the naive fix for not reading assets file during clean is attempted 
77+         [ Fact ] 
78+         public  void  It_can_clean_and_build_without_using_rebuild ( ) 
79+         { 
80+             var  testAsset  =  _testAssetsManager 
81+               . CopyTestAsset ( "HelloWorld" ) 
82+               . WithSource ( ) 
83+               . Restore ( Log ) ; 
84+ 
85+             var  cleanAndBuildCommand  =  new  MSBuildCommand ( Log ,  "Clean;Build" ,  testAsset . TestRoot ) ; 
86+ 
87+             cleanAndBuildCommand 
88+                 . Execute ( ) 
89+                 . Should ( ) 
90+                 . Pass ( ) ; 
91+         } 
5692    } 
5793} 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments