在Visual Studio中无法进行构建,但在msbuild中可以进行构建 [英] Build doesn't work from VisualStudio, but is ok from msbuild
问题描述
从Visual Studio中全新的控制台应用程序模板中,我编辑了.csproj
以构建另一个这样的项目:
From a brand new console application template in visual studio, I edited the .csproj
to build another project like this:
...
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="BeforeBuild">
<MSBuild Projects=".\other.mproj"/>
</Target>
...
other.mproj
所在的位置:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Target Name="Build">
<Message Text="kikou" />
</Target>
</Project>
过了一会儿,我发现除非在Visual Studio中卸载/重新加载项目,否则不会考虑修改other.mproj
的内容(例如,通过引入错误或将文本kikou
更改为其他内容).
After a while I discovered that modifying the content of other.mproj
(for instance, by introducing errors or changing text kikou
to something else) would not be taken into account unless unloading/reloading the project in visual studio.
使用'msbuild myproj.csproj'
从命令行进行构建可立即检测'other.mproj'
中的更改.因此,看起来Visual Studio正在使用other.mproj
文件的缓存版本进行工作.
Building from the command line with 'msbuild myproj.csproj'
immediatly detect changes in 'other.mproj'
. So it all looks like visual studio is working from a cached version of other.mproj
file.
为什么Visual Studio会缓存该其他脚本(甚至不包含在项目中),我该如何解决此问题?
Why is visual studio caching this other script (which is even not included to the project), and how can I solve this issue ?
更新:我也尝试过 UseHostCompilerIfAvailable ,它不起作用.
Update: I also tried this UseHostCompilerIfAvailable, it doesn't work.
NB1:我没有在.csproj
中添加other.mproj
作为项目引用,因为它根本不是.NET项目(它只是从其他输入创建.csproj
的资源文件,版本)
NB1: I didn't add other.mproj
as a project reference in the .csproj
because it is not a .NET project at all (it just creates resources files for the .csproj
from other inputs before the build)
NB2:我正在使用VS2010(10.0.10219.1SP1Rel + MSBuild 4.0.30319.1)
推荐答案
Visual Studio缓存所有MSBuild文件,这样做是出于性能方面的考虑.您将无法使用MSBuild解决此问题的方法.通过VS插件可以实现 ,但是我不确定100%如此.
Visual Studio caches all MSBuild files, this is done for performance reasons. You will not be able to have an MSBuild only way around this. It may be possible to achieve this via a VS add-in but I'm not 100% sure of that.
这篇关于在Visual Studio中无法进行构建,但在msbuild中可以进行构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!