Naylor
Naylor

Reputation: 903

Why doesn't <None Update="" /> work to change copy properties for all files in an SDK style csproj file?

I have an SDK style csproj file with three items that I need copied into the output. I modified the .csproj file as follows

  <ItemGroup>
    <None Update="Impls\SilSidePane\whitepixel.bmp" CopyToOutputDirectory="Always" />
    <None Update="Impls\SilSidePane\DefaultIcon.ico" CopyToOutputDirectory="Always" />
    <None Update="Controls\XMLViews\Resources\TextCacheModel_LanguageExplorer.xml" CopyToOutputDirectory="Always" />
  </ItemGroup>

The first two files were copied, but the third wasn't with no information in the logs as to why.

If I instead do the following then the file is copied.

  <ItemGroup>
    <None Remove="Controls\XMLViews\Resources\TextCacheModel_LanguageExplorer.xml" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="Controls\XMLViews\Resources\TextCacheModel_LanguageExplorer.xml" CopyToOutputDirectory="Always"/>
  </ItemGroup>

Can someone explain this different behavior?

Upvotes: 1

Views: 1109

Answers (1)

Martin Ullrich
Martin Ullrich

Reputation: 100611

Depeding on which SDK you're using, None may not be the default item that the xml file is added as.

For example, if TextCacheModel_LanguageExplorer.xml is an EmbeddedResource, then you need to use <EmbeddedResource Update="..." .../> instead.

Same goes for Content items (e.g. top-level json files in ASP.NET Core applications)

Upvotes: 1

Related Questions