@@ -136,5 +136,42 @@ async Task VerifyError()
136136 Assert . FileDoesNotExist ( result , IntermediateOutputPath , "Razor" , "Views" , "Home" , "Index.cshtml.g.cs" ) ;
137137 }
138138 }
139+
140+ [ Fact ]
141+ [ InitializeTestProject ( "AppWithP2PReference" , additionalProjects : "ClassLibrary" ) ]
142+ public async Task IncrementalBuild_WithP2P_WorksWhenBuildProjectReferencesIsDisabled ( )
143+ {
144+ // Simulates building the same way VS does by setting BuildProjectReferences=false.
145+ // With this flag, the only target called is GetCopyToOutputDirectoryItems on the referenced project.
146+ // We need to ensure that we continue providing Razor binaries and symbols as files to be copied over.
147+ var result = await DotnetMSBuild ( target : default ) ;
148+
149+ Assert . BuildPassed ( result ) ;
150+
151+ Assert . FileExists ( result , OutputPath , "AppWithP2PReference.dll" ) ;
152+ Assert . FileExists ( result , OutputPath , "AppWithP2PReference.Views.dll" ) ;
153+ Assert . FileExists ( result , OutputPath , "ClassLibrary.dll" ) ;
154+ Assert . FileExists ( result , OutputPath , "ClassLibrary.Views.dll" ) ;
155+ Assert . FileExists ( result , OutputPath , "ClassLibrary.Views.pdb" ) ;
156+
157+ result = await DotnetMSBuild ( target : "Clean" , "/p:BuildProjectReferences=false" , suppressRestore : true ) ;
158+ Assert . BuildPassed ( result ) ;
159+
160+ Assert . FileDoesNotExist ( result , OutputPath , "AppWithP2PReference.dll" ) ;
161+ Assert . FileDoesNotExist ( result , OutputPath , "AppWithP2PReference.Views.dll" ) ;
162+ Assert . FileDoesNotExist ( result , OutputPath , "ClassLibrary.dll" ) ;
163+ Assert . FileDoesNotExist ( result , OutputPath , "ClassLibrary.Views.dll" ) ;
164+ Assert . FileDoesNotExist ( result , OutputPath , "ClassLibrary.Views.pdb" ) ;
165+
166+ // dotnet msbuild /p:BuildProjectReferences=false
167+ result = await DotnetMSBuild ( target : default , "/p:BuildProjectReferences=false" , suppressRestore : true ) ;
168+
169+ Assert . BuildPassed ( result ) ;
170+ Assert . FileExists ( result , OutputPath , "AppWithP2PReference.dll" ) ;
171+ Assert . FileExists ( result , OutputPath , "AppWithP2PReference.Views.dll" ) ;
172+ Assert . FileExists ( result , OutputPath , "ClassLibrary.dll" ) ;
173+ Assert . FileExists ( result , OutputPath , "ClassLibrary.Views.dll" ) ;
174+ Assert . FileExists ( result , OutputPath , "ClassLibrary.Views.pdb" ) ;
175+ }
139176 }
140177}
0 commit comments