I am migrating an old .NET Framework csproj to dotnet core. What is the dotnet core equivalent of this:
<Compile Include="ServiceHost.Designer.cs">
<DependentUpon>ServiceHost.cs</DependentUpon>
</Compile>
I tried:
<ItemGroup>
<Compile Include="ServiceHost.Designer.cs">
<DependentUpon>ServiceHost.cs</DependentUpon>
</Compile>
</ItemGroup>
But I got this error:
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
How to open a CSPROJ file. CSPROJ files are are meant to be opened and edited in Microsoft Visual Studio (Windows, Mac) as part of Visual Studio projects. However, because CSPROJ files are XML files, you can open and edit them in any text or source code editor.
What is a CSProj file? Files with CSPROJ extension represent a C# project file that contains the list of files included in a project along with the references to system assemblies.
csproj files (WebApi is the name of my project). It is located as expected in the root of the project.
Since the items are included by default, you need to use Update
instead of Include
if you only want to modify the items that need this update and not list every cs file individually:
<ItemGroup>
<Compile Update="ServiceHost.Designer.cs">
<DependentUpon>ServiceHost.cs</DependentUpon>
</Compile>
</ItemGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With