简体   繁体   English

为什么不<none Update="“”" />是否可以更改 SDK 样式 csproj 文件中所有文件的复制属性?

[英]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.我有一个 SDK 样式的 csproj 文件,其中包含我需要复制到 output 中的三个项目。 I modified the.csproj file as follows我修改了.csproj文件如下

  <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?有人可以解释这种不同的行为吗?

Depeding on which SDK you're using, None may not be the default item that the xml file is added as.根据您使用的 SDK, None可能不是 xml 文件添加为的默认项目。

For example, if TextCacheModel_LanguageExplorer.xml is an EmbeddedResource , then you need to use <EmbeddedResource Update="...".../> instead.例如,如果TextCacheModel_LanguageExplorer.xmlEmbeddedResource ,那么您需要使用<EmbeddedResource Update="...".../>代替。

Same goes for Content items (eg top-level json files in ASP.NET Core applications) Content项也是如此(例如 ASP.NET 核心应用程序中的顶级 json 文件)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM