在 postsharp 版本 4.2.27 中,发布 web 项目工作正常。
当 postsharp nuget 包升级到 > 4.2.28 时,发布失败。尝试在 Microsoft.Web.Publishing.targets 中运行 TransformWebConfigCore 时失败。错误
Microsoft.Web.Publishing.targets(1483,5): Error : Could not open Source file: Could not find file '[Project Location]\Web.config;web.config'.
最佳答案
PostSharp 4.2.28 自动将 Web.config 添加到 Content
MSBuild ItemGroup。这就是您在错误消息中看到两次 web.config 的原因:
Microsoft.Web.Publishing.targets(1483,5): Error : Could not open Source file: Could not find file '[Project Location]\Web.config;web.config'.
如果您的 csproj 包含此元素:
<Content Include="Web.config" />
将Content
更改为None
:
<None Include="Web.config" />
确保在发布 Web 项目后包含 web.config 文件。
关于c# - 为什么 postsharp 导致 web 项目发布失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38303587/