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

1

5

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'.

Bronchi answered 11/7, 2016 at 9:33 Comment(1)
Do you use webconfig transforms? Also you couldcheck in the csproj file if The upgrade went successfull by checking if there are any references to 4.2.27Fireplug
J
10

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.

Jehial answered 12/7, 2016 at 13:28 Comment(2)
is there any reference to the PostSharp Documentation regarding your comment "PostSharp 4.2.28 ..."? The solution works but I am not confident that I fully understand the rationale. IMO, it seems rather hackish (I almost reinstalled my build server because of this error)Snowblind
Thank you so much for this answer. It was driving me crazy trying to find out the solution. I also noticed my SlowCheetah configs weren't working in VS, wonder if Postsharp is responsible for it.Dd

© 2022 - 2024 — McMap. All rights reserved.