在 .csproj 文件中,是什么? 为了?
与有何
<None Include="C:\foo.bar" />
不同
<Content Include="C:\foo.bar" />
?
How is
<None Include="C:\foo.bar" />
different from
<Content Include="C:\foo.bar" />
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
有关 的 MSDN 文章build action 属性解释了这些差异。
The MSDN article on the build action property explains the differences.
一个区别在于它们的发布方式; “无”项目不会包含在发布中,“内容”项目则会包含在内; 例如,在“发布”选项卡上的“应用程序文件”对话框中。
One difference is how they get published; "None" items don't get included in a publish, "Content" items do; for example, on the "Application Files" dialog on the Publish tab.
我不是 100% 确定(我阅读了 Build Action 属性的 MSDN 描述),但仅仅将该答案从 MSDN 复制到 StackOverflow 并不能完全回答我的问题。
None 和 Content 的区别仅对 Web 项目有影响。 对于命令行项目、WinForm 项目或 UnitTest 项目(在我的例子中)等。无和内容没有不同的行为。
MSDN:“项目输出组”或“内容输出组”只是 Web 项目中使用的术语,对吧?
I am not 100% sure (I read the MSDN description of Build Action property) but just copying that answer from MSDN to StackOverflow does not answer the question completely for me.
The difference of None and Content only has an effect on Web projects. For a command line project, WinForm project or UnitTest project (in my case) etc. None and Content have no different behavior.
MSDN: "project output group" or "Content output group" only terms used in a Web project, right?
在我的情况下,我的 MSBuild 文件有一个用于图像资源的
ItemGroup
,如下所示:虽然我的项目构建得很好,但这让我想知道为什么我混合了
Content
我的ItemGroup
中的None
项目类型元素。 这篇 MSDN 文章(适用于 Visual Studio 2010)给了我我正在寻找的指导:解决方案:按照此指导,使用文本编辑器,我将
Content
项类型元素更改为None
。另外,有关 MSBuild 项目的概述,请参阅此 MSDN 文章。
In my situation, my MSBuild file had an
ItemGroup
for image resources that appeared as follows:While my project was building fine, this left me wondering why I had a mix of
Content
andNone
item type elements in myItemGroup
. This MSDN article (for Visual Studio 2010) gave me the guidance I was looking for:Resolution: With this guidance, using a text editor, I changed the
Content
item type elements toNone
.Also, for an overview of MSBuild items, see this MSDN article.
内容文件不包含在构建中,但包含在发布中。
无 文件不包含在构建或发布中,除非您以这种方式配置它们。 例如,“复制到输出目录”设置为“始终”或“较新”,将导致它们包含在构建和发布中。
Content files are not included in a build, but are included in a publish.
None files are not included in a build or publish, unless they are configured that way by you. For instance, a "Copy to Output Directory" setting of "Always" or "Newer", will cause them to be included in both a build and publish.
我有一个不包含可编译项目的项目(它存储用于 jasmine 单元测试的 html 和 javascript)。
有一天,我的解决方案(包含所述项目)停止编译,说“项目中不存在目标“构建””。
我添加了一个导入来引入编译器,它在我的机器上运行良好,但在构建服务器上使用 msbuild 失败。
然后我将一行从 改为
,
它也可以在构建服务器上运行。
I have a project that contains no compilable items (it stores html and javascript for jasmine unit tests).
One day my solution (that contained said project) stopped compiling saying "The target "Build" does not exist in the project".
I added an import to bring in the compiler, which worked fine on my machine but failed using msbuild on the build server.
I then changed a line from
to
and it worked on the build server as well.
您不需要在模板项目文件中包含您在 .vstemplate 中定义的文件,否则它们会在创建和创建过程中丢失。 翻译过程。 它们被留在用于构建所有内容的临时文件夹中,然后不久后被删除。
You need None in a template project file to include files you define in the .vstemplate otherwise they are lost in the creation & translation process. They get left behind in the temp folder it uses to build everything and then deleted shortly after.
就我而言,.Pubxml 是无列表中的文件之一。 它不适用于解决方案构建或作为 Web 项目的静态文件。 但要将站点发布到 Azure,配置就在此处。
根据 Microsoft 文章,这些是我们在 .csproj 文件标记中看到的主要类型:
In my case .Pubxml is one of those files among None list. It's not meant for solution building or as a static file for web project. But to publish the site to Azure, the configurations are present in this.
As per Microsoft article these are the major types we see among .csproj file tags: