Domanda

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

Thanks.

È stato utile?

Soluzione

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! (copy happens and updates file on disk, but Visual Studio does not detect these changes and loads cached file).

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top