简体   繁体   English

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

[英]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. 现在,它就像一种魅力。

Thanks to Rob Butterworth 感谢Rob Butterworth

暂无
暂无

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

相关问题 在每次构建时在 Visual Studio C# 中运行预构建事件,而不总是触发目标重建 - Run pre-build event in Visual Studio C# on every build without always triggering target rebuild 将 C# 文件作为预构建事件运行 Visual Studio (.NET Core) - Run a C# file as a pre-build event Visual Studio (.NET Core) 在Visual Studio 2010中预构建 - Pre-build in Visual Studio 2010 如何在C#项目中以编程方式(例如在预生成事件中)以编程方式设置Visual Studio 2015的OutDir属性? - How can I set Visual Studio 2015's OutDir property programatically, e.g. in a pre-build event, in a C# project? 如何使用Visual Studio 2013预构建事件从构建中排除脚本? - How do i use Visual Studio 2013 Pre-Build event to exclude a script from build? 有没有办法从C#中的代码中修改Visual Studio 2008或2010项目预构建事件? - Is there a way to modify Visual Studio 2008 or 2010 project pre-build events from within your code in C#? 如何以编程方式将AssemblyInfo.cs更新为预生成事件(Visual Studio / msbuild) - How to programatically update AssemblyInfo.cs as a Pre-Build event (Visual Studio / msbuild) 在 Visual Studio 的预构建中使用 webpack - Using webpack in Visual Studio's pre-build C#-在预构建事件期间注册第三方COM DLL - C# - Register a third party COM DLL during a pre-build event C#预构建事件似乎没有扩展宏符号? - C# pre-build event doesn't appear to be expanding macro symbols?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM