Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
785 views
in Technique[技术] by (71.8m points)

.net core - 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.

question from:https://stackoverflow.com/questions/49784191/what-does-none-remove-mean-in-csproj

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)".


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...