• Modifying project files in Visual Studio during pre-build

     

     

     

    So it turns out that Visual Studio uses the application's cache if a file is open at build time instead of loading the file off disk...ok so this is good, when you want to save memory and speed up the build process. BUT when you are editing a source file that is being created/modified during the Pre-Build step, then you are in a little bit of trouble.

    After some digging, it turns out that it's a known process and in visual studio 2008 (at least) an additional option is not going to be added. So how do we get around this?

    Add the highlighted line to your projects build settings and it will force the applications to load the file from disk and not from its cache. It didn't take me too long to find this information out, but it's good to know if you get in a position that you need to do this.

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'PCRelease|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>
    <PlatformTarget>x86</PlatformTarget>
    </PropertyGroup>

     

    Source:

    Original Microsoft Feedback Post

     


    2 responses to “Modifying project files in Visual Studio during pre-build”


    • Dennis Roche

      Thanks – I did not know about that.

      What files are you generating in the pre-build step?


      • Rob Butterworth

        I’m generating a class that contains information about the user, time, date of build and last perforce sync from a list of directory, there might be a couple more values that I will add in the future.


     Leave a reply