File tree 5 files changed +51
-21
lines changed
Tasks/Microsoft.NET.Build.Tasks/targets
Tests/Microsoft.NET.Clean.Tests
5 files changed +51
-21
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,9 @@ function InitializeDotNetCli {
92
92
$env: DOTNET_INSTALL_DIR = $env: DotNetCoreSdkDir
93
93
}
94
94
95
+ # Save MSBuild crash files info to log directory so that they are captured as build artifacts
96
+ $env: MSBUILDDEBUGPATH = $LogDir
97
+
95
98
# Use dotnet installation specified in DOTNET_INSTALL_DIR if it contains the required SDK version,
96
99
# otherwise install the dotnet CLI and SDK to repo local .dotnet directory to avoid potential permission issues.
97
100
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 {
167
167
export DOTNET_INSTALL_DIR=" $DotNetCoreSdkDir "
168
168
fi
169
169
170
+ # Save MSBuild crash files info to log directory so that they are captured as build artifacts
171
+ export MSBUILDDEBUGPATH=" $log_dir "
172
+
170
173
ReadJson " $global_json_file " " version"
171
174
local dotnet_sdk_version=" $readjsonvalue "
172
175
local dotnet_root=" "
Original file line number Diff line number Diff line change @@ -92,14 +92,14 @@ Copyright (c) .NET Foundation. All rights reserved.
92
92
93
93
<PropertyGroup >
94
94
<CoreCleanDependsOn >
95
- SuppressAssetsLogMessages;
95
+ _SdkBeforeClean
96
96
$(CoreCleanDependsOn)
97
97
</CoreCleanDependsOn >
98
98
</PropertyGroup >
99
99
100
100
<PropertyGroup >
101
101
<RebuildDependsOn >
102
- UnsuppressAssetsLogMessages ;
102
+ _SdkBeforeRebuild ;
103
103
$(RebuildDependsOn)
104
104
</RebuildDependsOn >
105
105
</PropertyGroup >
@@ -200,29 +200,16 @@ Copyright (c) .NET Foundation. All rights reserved.
200
200
</ItemGroup >
201
201
</Target >
202
202
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 >
212
206
<EmitAssetsLogMessages >false</EmitAssetsLogMessages >
213
207
</PropertyGroup >
214
208
</Target >
215
209
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" >
224
211
<PropertyGroup >
225
- <UnsuppressAssetsLogMessages >true</ UnsuppressAssetsLogMessages >
212
+ <_CleaningWithoutRebuilding >false</ _CleaningWithoutRebuilding >
226
213
</PropertyGroup >
227
214
</Target >
228
215
Original file line number Diff line number Diff line change @@ -126,7 +126,8 @@ Copyright (c) .NET Foundation. All rights reserved.
126
126
</ResolvePackageDependenciesForBuildDependsOn >
127
127
</PropertyGroup >
128
128
<Target Name =" ResolvePackageDependenciesForBuild"
129
- Condition =" '$(DesignTimeBuild)' != 'true' Or Exists('$(ProjectAssetsFile)')"
129
+ Condition =" ('$(DesignTimeBuild)' != 'true' and '$(_CleaningWithoutRebuilding)' != 'true')
130
+ Or Exists('$(ProjectAssetsFile)')"
130
131
BeforeTargets =" AssignProjectConfiguration"
131
132
DependsOnTargets =" $(ResolvePackageDependenciesForBuildDependsOn)" />
132
133
Original file line number Diff line number Diff line change @@ -53,5 +53,41 @@ public void It_cleans_without_logging_assets_message()
53
53
. And
54
54
. NotHaveStdOutContaining ( "warning" ) ;
55
55
}
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
+ }
56
92
}
57
93
}
You can’t perform that action at this time.
0 commit comments