@@ -349,6 +349,65 @@ BuildCommand BuildProject(string buildNumber)
349349 }
350350 }
351351
352+ [ Fact ]
353+ public void It_includes_assembly_metadata ( )
354+ {
355+ var testAsset = _testAssetsManager
356+ . CopyTestAsset ( "HelloWorld" )
357+ . WithSource ( )
358+ . WithTargetFramework ( "netstandard2.0" )
359+ . WithProjectChanges ( ( path , project ) =>
360+ {
361+ var ns = project . Root . Name . Namespace ;
362+
363+ project . Root . Add (
364+ new XElement ( ns + "ItemGroup" ,
365+ new XElement ( ns + "AssemblyMetadata" ,
366+ new XAttribute ( "Include" , "MetadataKey" ) ,
367+ new XAttribute ( "Value" , "MetadataValue" ) ) ) ) ;
368+ } ) ;
369+
370+ new RestoreCommand ( Log , testAsset . TestRoot ) . Execute ( ) . Should ( ) . Pass ( ) ;
371+
372+ var buildCommand = new BuildCommand ( Log , testAsset . TestRoot ) ;
373+ buildCommand . Execute ( ) . Should ( ) . Pass ( ) ;
374+
375+ var assemblyPath = Path . Combine ( buildCommand . GetOutputDirectory ( "netstandard2.0" ) . FullName , "HelloWorld.dll" ) ;
376+ var info = AssemblyInfo . Get ( assemblyPath ) ;
377+
378+ AssemblyInfo . Get ( assemblyPath ) [ "AssemblyMetadataAttribute" ] . Should ( ) . Be ( "MetadataKey:MetadataValue" ) ;
379+ }
380+
381+ [ Fact ]
382+ public void It_respects_out_out_of_assembly_metadata ( )
383+ {
384+ var testAsset = _testAssetsManager
385+ . CopyTestAsset ( "HelloWorld" )
386+ . WithSource ( )
387+ . WithTargetFramework ( "netstandard2.0" )
388+ . WithProjectChanges ( ( path , project ) =>
389+ {
390+ var ns = project . Root . Name . Namespace ;
391+
392+ project . Root . Add (
393+ new XElement ( ns + "PropertyGroup" ,
394+ new XElement ( ns + "GenerateAssemblyMetadataAttributes" , "false" ) ) ,
395+ new XElement ( ns + "ItemGroup" ,
396+ new XElement ( ns + "AssemblyMetadata" ,
397+ new XAttribute ( "Include" , "MetadataKey" ) ,
398+ new XAttribute ( "Value" , "MetadataValue" ) ) ) ) ;
399+ } ) ;
400+
401+ new RestoreCommand ( Log , testAsset . TestRoot ) . Execute ( ) . Should ( ) . Pass ( ) ;
402+
403+ var buildCommand = new BuildCommand ( Log , testAsset . TestRoot ) ;
404+ buildCommand . Execute ( ) . Should ( ) . Pass ( ) ;
405+
406+ var assemblyPath = Path . Combine ( buildCommand . GetOutputDirectory ( "netstandard2.0" ) . FullName , "HelloWorld.dll" ) ;
407+
408+ Assert . False ( AssemblyInfo . Get ( assemblyPath ) . ContainsKey ( "AssemblyMetadataAttribute" ) ) ;
409+ }
410+
352411 [ Theory ]
353412 [ InlineData ( false , false , false ) ]
354413 [ InlineData ( true , false , true ) ]
@@ -434,7 +493,6 @@ public void GenerateUserSecretsForTestProject()
434493 var assemblyPath = Path . Combine ( buildCommand . GetOutputDirectory ( testTestProject . TargetFrameworks ) . FullName , testTestProject . Name + ".dll" ) ;
435494
436495 AssemblyInfo . Get ( assemblyPath ) [ "UserSecretsIdAttribute" ] . Should ( ) . Be ( "SecretsIdValue" ) ;
437-
438496 }
439497 }
440498}
0 commit comments