1. 程式人生 > >[VS] - "包含了重復的“Content”項。.NET SDK 默認情況下包括你項目中的“Content”項。" 之解決

[VS] - "包含了重復的“Content”項。.NET SDK 默認情況下包括你項目中的“Content”項。" 之解決

rom direct 背景 cto dir 項目文件 con them rop

背景

VS 2017 升級至 VS 2017 v15.3 後,.Net Core 1.1 應用編譯報錯:

Error: 包含了重復的“Content”項。.NET SDK 默認情況下包括你項目中的“Content”項。
可以從項目文件中刪除這些項,或者如果希望將其顯示包含在項目文件中,則可以將“EnableDefaultContentItems”屬性設置為“false”。

Error : Duplicate ‘Content‘ items were included. The .NET SDK includes ‘Content‘ items from your project directory by default.


You can either remove these items from your project file, or set the ‘EnableDefaultContentItems‘ property to ‘false‘ if you want to explicitly include them in your project file.

解決

在 .csproj 項目文件中添加如下配置項,重啟解決方案編譯成功。

  <PropertyGroup>
    <EnableDefaultContentItems>false</EnableDefaultContentItems
> </PropertyGroup>

參考資料

https://stackoverflow.com/a/45586177

[VS] - "包含了重復的“Content”項。.NET SDK 默認情況下包括你項目中的“Content”項。" 之解決