Visual Studio的C#不建立一个由预生成事件变化的文件 [英] visual studio c# does not build files that were change by pre-build event
问题描述
我在Visual Studio 2010中的C#解决方案。
在预生成事件我执行,在该溶液中改变的文件的命令。
更新后的文件是不是建在当前构建。
我怎么能做到这一点的文件,用的变化,将建在当前构建???
I have solution in visual studio 2010 c#. In the pre build event I execute command that change files in this solution. The updated file is not built in the current build. How can I do that the file, with the changes, will be built in the current build???
感谢。
推荐答案
好吧,看来我想通了你的问题。
Ok, it seems i figured out your issue.
我已经建立了一个简单的控制台应用程序,此事件:
I have set up a simple Console app and this event:
<PreBuildEvent>copy "D:\Program.cs" "D:\Projects\PreBuildFileModification\FileModification\Program.cs" /Y</PreBuildEvent>
唉,这也不行! (复制发生和更新磁盘上的文件,但Visual Studio中不检测这些变化和负载缓存文件)
And alas, this does not work! (copy happens and updates file on disk, but Visual Studio does not detect these changes and loads cached file).
解决方案是增加
<UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>
在您的配置,例如:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>
</PropertyGroup>
和现在这个工程就像一个魅力。
And now this works like a charm.
这篇关于Visual Studio的C#不建立一个由预生成事件变化的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!