@@ -1097,5 +1097,148 @@ public void when_dependency_is_development_dependency_then_can_explicitly_pack_i
10971097 Assert . Equal ( "ThisAssembly.Constants" , manifest . Metadata . DependencyGroups . First ( ) . Packages . First ( ) . Id ) ;
10981098 }
10991099 }
1100+
1101+ [ Fact ]
1102+ public void when_produce_reference_assembly_then_includes_ref_assembly ( )
1103+ {
1104+ var result = Builder . BuildProject (
1105+ """
1106+ <Project Sdk="Microsoft.NET.Sdk">
1107+ <PropertyGroup>
1108+ <TargetFramework>net8.0</TargetFramework>
1109+ <ProduceReferenceAssembly>true</ProduceReferenceAssembly>
1110+ </PropertyGroup>
1111+ </Project>
1112+ """ , output : output ) ;
1113+
1114+ result . AssertSuccess ( output ) ;
1115+
1116+ // Should have the main assembly in lib
1117+ Assert . Contains ( result . Items , item => item . Matches ( new
1118+ {
1119+ Extension = ".dll" ,
1120+ PackFolder = PackFolderKind . Lib
1121+ } ) ) ;
1122+
1123+ // Should also have the reference assembly in ref
1124+ Assert . Contains ( result . Items , item => item . Matches ( new
1125+ {
1126+ Extension = ".dll" ,
1127+ PackFolder = PackFolderKind . Ref
1128+ } ) ) ;
1129+ }
1130+
1131+ [ Fact ]
1132+ public void when_produce_reference_assembly_false_then_does_not_include_ref_assembly ( )
1133+ {
1134+ var result = Builder . BuildProject (
1135+ """
1136+ <Project Sdk="Microsoft.NET.Sdk">
1137+ <PropertyGroup>
1138+ <TargetFramework>net8.0</TargetFramework>
1139+ <ProduceReferenceAssembly>false</ProduceReferenceAssembly>
1140+ </PropertyGroup>
1141+ </Project>
1142+ """ , output : output ) ;
1143+
1144+ result . AssertSuccess ( output ) ;
1145+
1146+ // Should have the main assembly in lib
1147+ Assert . Contains ( result . Items , item => item . Matches ( new
1148+ {
1149+ Extension = ".dll" ,
1150+ PackFolder = PackFolderKind . Lib
1151+ } ) ) ;
1152+
1153+ // Should NOT have a reference assembly in ref
1154+ Assert . DoesNotContain ( result . Items , item => item . Matches ( new
1155+ {
1156+ PackFolder = PackFolderKind . Ref
1157+ } ) ) ;
1158+ }
1159+
1160+ [ Fact ]
1161+ public void when_produce_reference_assembly_but_pack_build_output_false_then_does_not_include_ref_assembly ( )
1162+ {
1163+ var result = Builder . BuildProject (
1164+ """
1165+ <Project Sdk="Microsoft.NET.Sdk">
1166+ <PropertyGroup>
1167+ <TargetFramework>net8.0</TargetFramework>
1168+ <ProduceReferenceAssembly>true</ProduceReferenceAssembly>
1169+ <PackBuildOutput>false</PackBuildOutput>
1170+ </PropertyGroup>
1171+ </Project>
1172+ """ , output : output ) ;
1173+
1174+ result . AssertSuccess ( output ) ;
1175+
1176+ // Should NOT have the main assembly in lib
1177+ Assert . DoesNotContain ( result . Items , item => item . Matches ( new
1178+ {
1179+ Extension = ".dll" ,
1180+ PackFolder = PackFolderKind . Lib
1181+ } ) ) ;
1182+
1183+ // Should NOT have a reference assembly in ref either
1184+ Assert . DoesNotContain ( result . Items , item => item . Matches ( new
1185+ {
1186+ PackFolder = PackFolderKind . Ref
1187+ } ) ) ;
1188+ }
1189+
1190+ [ Fact ]
1191+ public void when_produce_reference_assembly_can_opt_out_with_pack_ref_assembly_false ( )
1192+ {
1193+ var result = Builder . BuildProject (
1194+ """
1195+ <Project Sdk="Microsoft.NET.Sdk">
1196+ <PropertyGroup>
1197+ <TargetFramework>net8.0</TargetFramework>
1198+ <ProduceReferenceAssembly>true</ProduceReferenceAssembly>
1199+ <PackRefAssembly>false</PackRefAssembly>
1200+ </PropertyGroup>
1201+ </Project>
1202+ """ , output : output ) ;
1203+
1204+ result . AssertSuccess ( output ) ;
1205+
1206+ // Should have the main assembly in lib
1207+ Assert . Contains ( result . Items , item => item . Matches ( new
1208+ {
1209+ Extension = ".dll" ,
1210+ PackFolder = PackFolderKind . Lib
1211+ } ) ) ;
1212+
1213+ // Should NOT have a reference assembly in ref
1214+ Assert . DoesNotContain ( result . Items , item => item . Matches ( new
1215+ {
1216+ PackFolder = PackFolderKind . Ref
1217+ } ) ) ;
1218+ }
1219+
1220+ [ Fact ]
1221+ public void when_produce_reference_assembly_then_ref_assembly_is_framework_specific ( )
1222+ {
1223+ var result = Builder . BuildProject (
1224+ """
1225+ <Project Sdk="Microsoft.NET.Sdk">
1226+ <PropertyGroup>
1227+ <TargetFramework>net8.0</TargetFramework>
1228+ <ProduceReferenceAssembly>true</ProduceReferenceAssembly>
1229+ <IsPackable>true</IsPackable>
1230+ </PropertyGroup>
1231+ </Project>
1232+ """ , output : output ) ;
1233+
1234+ result . AssertSuccess ( output ) ;
1235+
1236+ // The ref assembly should have a package path that includes the TFM
1237+ Assert . Contains ( result . Items , item => item . Matches ( new
1238+ {
1239+ PackFolder = PackFolderKind . Ref ,
1240+ PackagePath = "ref/net8.0/scenario.dll"
1241+ } ) ) ;
1242+ }
11001243 }
11011244}
0 commit comments