Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is postsharp causing a web project to fail on publish?

Tags:

c#

postsharp

In version 4.2.27 of postsharp publishing a web project works correct.

When the postsharp nuget package is upgraded to > 4.2.28 the publish fails. It fails when trying to run TransformWebConfigCore in Microsoft.Web.Publishing.targets. The error

Microsoft.Web.Publishing.targets(1483,5): Error : Could not open Source file: Could not find file '[Project Location]\Web.config;web.config'.

like image 380
Tim Pragnell Avatar asked Dec 24 '22 03:12

Tim Pragnell


1 Answers

PostSharp 4.2.28 adds Web.config to Content MSBuild ItemGroup automatically. It is the reason why you see web.config twice in the error message:

Microsoft.Web.Publishing.targets(1483,5): Error : Could not open Source file: Could not find file '[Project Location]\Web.config;web.config'.

If your csproj contains this element:

<Content Include="Web.config" />

Change Content to None:

<None Include="Web.config" />

Make sure that the web.config file is included after publishing your web project.

like image 187
Jakub Linhart Avatar answered Jan 05 '23 00:01

Jakub Linhart