是否可以从 csproj 文件中知道是使用 devenv 还是 msbuild 来运行它?

发布于 2024-07-26 18:09:53 字数 311 浏览 3 评论 0原文

动机: 我在构建过程中集成了 fxcop,这使得每次目标更改时或者只要上次运行 fxcop 出现警告时都会运行 fxcopcmd.exe。

但是当一个人在工作室工作时,devenv.exe 经常会出于某种原因决定在后台编译该项目。 例如,当我向解决方案添加新项目时,我注意到 fxcopcmd.exe 运行,这意味着后台构建已开始。 也有其他时间。

所以,我希望在使用 devenv 构建时抑制 fxcop。 我们的 CI 服务器使用 msbuild 构建,所以没有问题。

顺便说一句,如果有一种方法可以禁用后台构建,那就太好了。

Motivation:
I have fxcop integrated in the build process, which makes fxcopcmd.exe run each time the target has changed or as long as there are warnings from the previous run of fxcop.

But when one works in the studio, devenv.exe often decides to compile the project in background for whatever reasons. For example, when I add a new project to the solution I notice that fxcopcmd.exe runs, meaning a background build has started. There are also other times as well.

So, I wish to suppress fxcop when built with devenv. Our CI server builds using msbuild, so no problem there.

BTW, if there is a way to disable the background builds, that could be great.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情愿 2024-08-02 18:09:53

有一个属性 BuildingInsideVisualStudio 可以告诉您这一点。

例如,将 msbuild.exedevenv.exe 与 .csproj 一起使用时的结果与定义为

<Target Name="AfterBuild">
  <Message Text="BuildingInsideVisualStudio: $(BuildingInsideVisualStudio)" Importance="high"/>
</Target>

Sayed Ibrahim Hashimi

My Book 的以下 AfterBuild 目标进行比较: Microsoft 构建引擎内部:使用 MSBuild 和 Team Foundation Build

There is a property BuildingInsideVisualStudio which will tell you this.

For example compare the result when using msbuild.exe and devenv.exe with a .csproj with the following AfterBuild target defined

<Target Name="AfterBuild">
  <Message Text="BuildingInsideVisualStudio: $(BuildingInsideVisualStudio)" Importance="high"/>
</Target>

Sayed Ibrahim Hashimi

My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build

断爱 2024-08-02 18:09:53

我唯一能想到的就是

  1. 创建一个不同的构建类型(例如 debug_and_rules、release_and_rules 等)。 我认为 ms build 可以读到这个。
  2. 让 CI 服务器在构建项目的同时调用 fxcop exe。 这是我在fxcop集成到VS之前经常做的事情。
  3. 让 msbuild 设置 ms build 可以读取的设置或编译器标志。 我不确定这是否有效。

后台编译器是在 VS 2008 中添加到 C# 中的,据我所知,它是不可配置的。 VS 2010 应该是超级可配置的,所以也许这会改变

编辑:格式化我的列表更好一点

The only thing I can think of is to either

  1. create a different build type (such as debug_and_rules, release_and_rules, etc). I think ms build could read this.
  2. have your CI server call the fxcop exe separate from building the project. This is what I used to do before fxcop was integrated into VS.
  3. have msbuild set a setting or compiler flag that ms build could read. I'm not sure if this would work.

The background compiler was added in VS 2008 to C#, and as far as I know, is not configurable. VS 2010 is supposed to be ultra configurable so maybe that will change

Edit: formatted my list a little better

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文