gpt4 book ai didi

c# - 作为子项的 DotNet Core .csproj 代码文件

转载 作者:太空狗 更新时间:2023-10-29 22:35:46 25 4
gpt4 key购买 nike

我正在将旧的 .NET Framework csproj 迁移到 dotnet core。与此等效的 dotnet 核心是什么:

<Compile Include="ServiceHost.Designer.cs">
<DependentUpon>ServiceHost.cs</DependentUpon>
</Compile>

我试过:

<ItemGroup>
<Compile Include="ServiceHost.Designer.cs">
<DependentUpon>ServiceHost.cs</DependentUpon>
</Compile>
</ItemGroup>

但是我得到了这个错误:

Duplicate 'Compile' items were included. The .NET SDK includes 'Compile' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultCompileItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'ProjectInstaller.Designer.cs'; 'ServiceHost.Designer.cs' TestWindowsService C:\Program Files\dotnet\sdk\2.1.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets

最佳答案

由于项目默认包含,如果您只想修改需要此更新的项目而不列出每个 cs,则需要使用 Update 而不是 Include单独归档:

<ItemGroup>
<Compile Update="ServiceHost.Designer.cs">
<DependentUpon>ServiceHost.cs</DependentUpon>
</Compile>
</ItemGroup>

关于c# - 作为子项的 DotNet Core .csproj 代码文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48424567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com