Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does <None Remove="..." /> mean in csproj?

I'm working with a dotnet core csproj and I've added a new file. It doesn't initially get added to the csproj at all because of convention over configuration. But as soon as I change its Build Action from None to Embedded resource, two entries are written to the csproj file:

<None Remove="MyFile.sql" />

and

<EmbeddedResource Include="MyFile.sql" />

What does that first entry mean? It seems superfluous to me.

like image 917
Joe Phillips Avatar asked Apr 11 '18 20:04

Joe Phillips


People also ask

What is none include in Csproj?

None - The file is not included in the project output group and is not compiled in the build process. An example is a text file that contains documentation, such as a Readme file. Content - The file is not compiled, but is included in the Content output group. For example, this setting is the default value for an .

How do I edit a Csproj file?

Right-click on the project (tagged as unavailable in solution explorer) and click "Edit yourproj. csproj". This will open up your CSPROJ file for editing. After making the changes you want, save, and close the file.

What does Csproj file do?

CSPROJ files define a project's content, platform requirements, versioning information, and web server or database server settings. They also list the files that are part of the project.

Do I need to check in Csproj?

I think what i have concluded is that the CSPROJ and SLN files do not get checked into TFS and must be manually passed to each developer when they initially get latest from TFS.


1 Answers

The sdk-style projects have a few automatic includes.

By default, the sdk has something like <None Include="**/*"> (simplified) that is added (included) before your project's contents. But you don't want your file to be in the "None" set, but in the "EmbeddedResource" set.

MSBuild doesn't have any problem with the files being in more than one item group, but it should only be in one so IDEs don't get confused (and display the file only once an show the correct build action).

So the two statements mean "remove it from the None set (items) and add it to the EmbeddedResource set (items)".

like image 93
Martin Ullrich Avatar answered Nov 13 '22 19:11

Martin Ullrich