File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
test/Microsoft.NET.Build.Tests Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -258,5 +258,44 @@ public void AnalyzersAreConflictResolved()
258
258
. Should ( )
259
259
. Pass ( ) ;
260
260
}
261
+
262
+ [ Theory ]
263
+ [ InlineData ( true ) ]
264
+ [ InlineData ( false ) ]
265
+ public void PlatformPackagesCanBePruned ( bool prunePackages )
266
+ {
267
+ var referencedProject = new TestProject ( "ReferencedProject" )
268
+ {
269
+ TargetFrameworks = ToolsetInfo . CurrentTargetFramework ,
270
+ IsExe = false
271
+ } ;
272
+ referencedProject . PackageReferences . Add ( new TestPackageReference ( "System.Text.Json" , "8.0.0" ) ) ;
273
+
274
+ var testProject = new TestProject ( )
275
+ {
276
+ TargetFrameworks = ToolsetInfo . CurrentTargetFramework
277
+ } ;
278
+
279
+ testProject . AdditionalProperties [ "RestoreEnablePackagePruning" ] = prunePackages . ToString ( ) ;
280
+ testProject . ReferencedProjects . Add ( referencedProject ) ;
281
+
282
+ var testAsset = _testAssetsManager . CreateTestProject ( testProject , identifier : prunePackages . ToString ( ) ) ;
283
+
284
+ var buildCommand = new BuildCommand ( testAsset ) ;
285
+
286
+ buildCommand . Execute ( ) . Should ( ) . Pass ( ) ;
287
+
288
+ var assetsFilePath = Path . Combine ( buildCommand . GetBaseIntermediateDirectory ( ) . FullName , "project.assets.json" ) ;
289
+
290
+ // TODO: parse and process assets file instead of just loooking for string in it
291
+ if ( prunePackages )
292
+ {
293
+ File . ReadAllText ( assetsFilePath ) . Should ( ) . NotContain ( "System.Text.Json" ) ;
294
+ }
295
+ else
296
+ {
297
+ File . ReadAllText ( assetsFilePath ) . Should ( ) . Contain ( "System.Text.Json" ) ;
298
+ }
299
+ }
261
300
}
262
301
}
You can’t perform that action at this time.
0 commit comments