如果我在.csproj文件中添加额外的“非标准”目标,VS2008会呕吐吗?

时间:2022-08-15 00:31:26

Will Visual Studio choke on customized .csproj files?

Visual Studio会阻塞定制的.csproj文件吗?

For example, I wanted to add a Target to update the version number in all AssemblyInfo.cs files. I plan to invoke this from the command line with MSbuild.

例如,我想添加一个Target来更新所有AssemblyInfo.cs文件中的版本号。我计划从MSbuild的命令行调用它。

As another example, I would like to include the build timestamp into the compile, like so. This would be a pre-compile step (I guess), and unlike the example above, this one would run from within a build inside Visual Studio.

作为另一个例子,我想将构建时间戳包含在编译中,就像这样。这将是一个预编译步骤(我猜),与上面的示例不同,这个将在Visual Studio内部的构建中运行。

Will VS be ok with this?

VS会好吗?

2 个解决方案

#1


As long as the code is a valid MSBuild extension, Visual Studio should be able to handle it. Under the hood the project files are really just MSBuild files and MSBuild does the dirty work of the VS build system. So as long as the file remains a valid MSBuild file it should be just fine.

只要代码是有效的MSBuild扩展,Visual Studio就应该能够处理它。在幕后,项目文件实际上只是MSBuild文件,MSBuild完成VS构建系统的脏工作。因此,只要文件仍然是有效的MSBuild文件,它应该没问题。

#2


Yes it does allow customizations. We integrated FxCop with our release-mode builds this way.

是的,它确实允许自定义。我们通过这种方式将FxCop与我们的发布模式构建集成在一起。

It will complain when you first load the project file after it's been edited, saying "it's been tampered with, do you wish to continue loading?" Just hit yes and continue on your merry way. It also lets you check a box to ignore the rest of the projects in the solution for the same warning.

当你第一次加载项目文件后,它会抱怨它说“它被篡改了,你想继续加载吗?”只需点击是,继续你的快乐方式。它还允许您选中一个框以忽略解决方案中用于相同警告的其余项目。

#1


As long as the code is a valid MSBuild extension, Visual Studio should be able to handle it. Under the hood the project files are really just MSBuild files and MSBuild does the dirty work of the VS build system. So as long as the file remains a valid MSBuild file it should be just fine.

只要代码是有效的MSBuild扩展,Visual Studio就应该能够处理它。在幕后,项目文件实际上只是MSBuild文件,MSBuild完成VS构建系统的脏工作。因此,只要文件仍然是有效的MSBuild文件,它应该没问题。

#2


Yes it does allow customizations. We integrated FxCop with our release-mode builds this way.

是的,它确实允许自定义。我们通过这种方式将FxCop与我们的发布模式构建集成在一起。

It will complain when you first load the project file after it's been edited, saying "it's been tampered with, do you wish to continue loading?" Just hit yes and continue on your merry way. It also lets you check a box to ignore the rest of the projects in the solution for the same warning.

当你第一次加载项目文件后,它会抱怨它说“它被篡改了,你想继续加载吗?”只需点击是,继续你的快乐方式。它还允许您选中一个框以忽略解决方案中用于相同警告的其余项目。