繁体   English   中英

Visual Studio C#不会生成因预生成事件而更改的文件

[英]visual studio c# does not build files that were change by pre-build event

我在Visual Studio 2010 C#中有解决方案。 在预构建事件中,我执行在此解决方案中更改文件的命令。 更新的文件不是在当前版本中构建的。 我该怎么做,更改后的文件将在当前版本中构建???

谢谢。

好的,看来我知道了您的问题。

我已经建立了一个简单的控制台应用程序,并且发生了以下事件:

<PreBuildEvent>copy "D:\Program.cs" "D:\Projects\PreBuildFileModification\FileModification\Program.cs" /Y</PreBuildEvent>

a,这行不通! (将进行复制并更新磁盘上的文件,但是Visual Studio不会检测到这些更改并加载缓存的文件)。

解决方法是添加:

<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>

现在,它就像一种魅力。

感谢Rob Butterworth

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM