You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// <summary>
/// Author: Salvatore Previti - 08-April-2009.
///
/// Visual studio host compiler keeps a cache of files during the MSBuild step, so they are not readed from disk.
/// This is ok for performance and intellisense, right, but this introduces also some subtle bug!
///
/// See forum thread "Generated Code Not Building - VS Caching Problem?" at http://social.technet.microsoft.com/Forums/en-US/msbuild/thread/14bb304d-d8e6-4227-bc2b-e2e6d4f979be?ppud=4 for more informations.
/// This task contains a simple but effective work around to this caching bug :)
///
/// How it works:
///
/// Visual studio keeps MSBuild Tasks dll loaded also between different compilations in the same appdomain where MSBuild is executed.
/// Due to this fact, we can keep some states (static variables) between different compilations during the same development session.
/// This class, infact, uses a static synclocked dictionary to keep states between different compilations.
/// Each time static function UpdateFileUsageCount is called with the same prefix and with the same filename (case insensitive), the resulting value is incremented.
///
/// There is another "feature" (bug?) in visual studio cache mechanism... <Compile Include="c:\test.cs"> and <Compile Include="c:\test.cs ">
/// are considered different files, so, they are cached as two different files (look the space character in "test.cs " in the second Compile tag).
/// MSBuild and all filesystems, instead, treat both files as the same :)
///
/// So the solution! Each time we generate a file, we use a different number of spaces using our in-ram dictionary.
/// The static function that does this is UpdateSpaces.
/// During tests, a single space seems sufficient, but to be safe, I used MaxSpaces constant to use more than one space.
///
/// This system has some drawback, though:
/// 1) You need to use this Task, so, you have to include a DLL and add some tags to your MSBuild project.
/// 2) This should works for full pathed filenames.
/// 3) Not garbage collector friendly - some objects (internal static dictionary and some Visual Studio cached files) will never be released and there is no way to release them.
/// This is a small amount of RAM, though, and should not be a problem during development.
/// During command-line MSBuild this problem can be ignored.
/// </summary>
Original issue reported on code.google.com by Dmitry.G...@gmail.com on 17 Oct 2012 at 5:53
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
Dmitry.G...@gmail.com
on 17 Oct 2012 at 5:53The text was updated successfully, but these errors were encountered: