当项目迁移到 SDK 样式,同时保留显式内容项时,就会发生这种情况。
修复:添加
<EnableWebFormsDefaultItems>false</EnableWebFormsDefaultItems>
或删除显式项目。
原答案复制自: https://github.com/CZEMacLeod/MSBuild.SDK.SystemWeb/issues/60
最后我们对 CSPROJ 文件本身有些混乱......对我们有用的是:
<ItemGroup>
<None Include="Web.Debug.config">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>Web.config</DependentUpon>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<None Include="Web.Release.config">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>Web.config</DependentUpon>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<None Include="Web.Test.config">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>Web.config</DependentUpon>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
</ItemGroup>
.....
<ItemGroup>
<Content Update="Web.config">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
<TransformOnBuild>true</TransformOnBuild>
</Content>
<Content Update="Web.Debug.config">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>Web.config</DependentUpon>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
<Content Update="Web.Release.config">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>Web.config</DependentUpon>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>