强制Visual Studio在开始调试时进行重建 [英] Force Visual Studio to rebuild on Start Debugging

查看:80
本文介绍了强制Visual Studio在开始调试时进行重建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次更改后,如何告诉Visual Studio重新构建?

问题是我修改了未引用项目的csproj(因为它是运行时依赖项)。

The issue is that I have modified a csproj that is not referenced a project (because it's run-time dependency).

因此,例如,在我的csproj文件中:

So for example, in my csproj file I have:

<Import Project=".\UnreferencedProjects-Developer.targets" />

在我的 .targets 文件中, :

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="BuildDependencyForDevelopers" AfterTargets="Build">
    <Message Text="========================================" />
    <Message Text="Developer Building Unreferenced Projects" />
    <Message Text="========================================" />
    <!--MSBuild Projects="$(ProjectToBuild)"-->
    <MSBuild Projects="../OtherProject/OtherProject.csproj">
      <Output ItemName="ProjectOutputs" TaskParameter="TargetOutputs"/>
    </MSBuild>
    <Message Text="@(ProjectOutputs)"/>
    <Message Text="=======================================" />
    <Message Text="Developer Copying Unreferenced Projects" />
    <Message Text="=======================================" />
    <Copy SourceFiles="$(ProjectDir)\..\OtherProject\bin\$(Configuration)\OtherProject.dll" DestinationFolder="$(OutDir)" ContinueOnError="true"/>
    <Copy SourceFiles="$(ProjectDir)\..\OtherProject\bin\$(Configuration)\OtherProject.pdb" DestinationFolder="$(OutDir)" ContinueOnError="true"/>
    <Message Text="=============================================" />
    <Message Text="Developer Finished with Unreferenced Projects" />
    <Message Text="=============================================" />
  </Target>
</Project>

问题是 .targets。该文件似乎仅在手动构建/重建上执行,而不在开始调试上执行。

The issue is that the .targets. file seems to only execute on a manual build/rebuild, and not on a Start Debugging.

所有配置均设置为构建。选项->项目和解决方案->生成并运行->运行时,当项目过时时:始终进行构建。

All Configurations are set to Build. Options -> Project and Solutions -> Build and Run -> On Run, when projects are out of date: Always build.

我认为问题在于,因为该项目是未引用的,当我开始调试时,没有过时的项目,因此它在没有构建/重建的情况下启动。我如何强制其从字面上总是(重新)构建

I think the issue is that because the project is unreferenced, when I Start Debugging there are no out of date projects so it launches without a build/rebuild. How do I force it to literally always (re)build.

推荐答案

添加到项目中:

<PropertyGroup><DisableFastUpToDateCheck>true</DisableFastUpToDateCheck></PropertyGroup>

关键字此处是快速更新检查:Visual Studio在调试时会使用它来避免启动msbuild。

Keyword here is "fast update check": Visual Studio uses it when you debug to avoid even starting up msbuild.

相关主题:在VS2013中单击构建时始终运行的MSBuild目标

背景信息: https://msdn.microsoft.com/library/ms171468%28v=vs.110%29.aspx


如果您在Visual Studio UI中开始调试(通过选择F5键或选择Debug,则在菜单栏),构建过程会使用快速更新检查来提高性能。在某些情况下,自定义版本会创建依次生成的文件,而快速更新检查无法正确识别更改的文件。需要更彻底的更新检查的项目可以通过设置环境变量DISABLEFASTUPTODATECHECK = 1来关闭快速检查。或者,项目可以在项目或项目导入的文件中将其设置为MSBuild属性。

If you start debugging in the in Visual Studio UI (either by choosing the F5 key or by choosing Debug, Start Debugging on the menu bar), the build process uses a fast update check to improve performance. In some cases where customized builds create files that get built in turn, the fast update check does not correctly identify the changed files. Projects that need more thorough update checks can turn off the fast checking by setting the environment variable DISABLEFASTUPTODATECHECK=1. Alternatively, projects can set this as an MSBuild property in the project or in a file the project imports.

这篇关于强制Visual Studio在开始调试时进行重建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆