[英]visual studio c# does not build files that were change by pre-build event
I have solution in visual studio 2010 c#. 我在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??? 我该怎么做,更改后的文件将在当前版本中构建???
Thanks. 谢谢。
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>
And alas, this does not work! a,这行不通! (copy happens and updates file on disk, but Visual Studio does not detect these changes and loads cached file). (将进行复制并更新磁盘上的文件,但是Visual Studio不会检测到这些更改并加载缓存的文件)。
Solution is to add: 解决方法是添加:
<UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>
In your configuration, eg: 在您的配置中,例如:
<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. 现在,它就像一种魅力。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.