Search code examples
visual-studio-2010msbuildtrackerresgen

How to change the Resgen command line in a VS.NET project?


Having an issue with a ResGen call during a build of a .NET 2.0 project from within Visual Studio .NET 2010, this thread suggests:

Add this to your MSBUILD command-line: /p:ResGenExecuteAsTool=true;ResGenToolArchitecture=ManagedIL;ResGenTrackerSdkPath="%programfiles(x86)%\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\x64"

I've searched for hours without success trying to find a way to do this from within my Visual Studio .NET project.

Therefore my question is:

How can I change the MSBUILD command line of a .NET 2.0 (class library) project in Visual Studio 2010?

I have no fear changing my ".csproj" file, I would prefer not to change MSBuild files that were shipped with Visual Studio, if this is possible.

Update and solution:

Thanks to Oded's comment and answer, I added the following two lines:

<ResGenTrackerSdkPath>%programfiles(x86)%\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\x64</ResGenTrackerSdkPath>
<TrackFileAccess>false</TrackFileAccess>

right inside the very first <PropertyGroup> section of my ".csproj" file (i.e. after line 3). This made the file compile successfully!

I now check and see whether it also runs successfully.


Solution

  • Like all properties in MSBuild, what you can pass in through the command line can be added in the project file in XML elements instead.

    For example:

    <ResGenTrackerSdkPath>%programfiles(x86)%\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\x64</ResGenTrackerSdkPath>
    

    And:

    <ResGenExecuteAsTool>true</ResGenExecuteAsTool>
    

    etc...