.NET Reference “Copy Local” True / False Being Set Based on Contents of GAC

前端 未结 5 1112
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-06 05:08

We had a very interesting problem with a Win Forms project. It\'s been resolved. We know what happened, but we want to understand why it happened. This may help other people

5条回答
  •  余生分开走
    2020-12-06 05:38

    I found a solution for us on our build servers.

    Problem: In a specific date for no reason (I now assume the file was added to the GAC) the assembly System.Web.MVC.dll disappeared from many of our projects. I am sure this applies to any dll with the issue.

    Solution: In visual studio change the reference (assuming Copy Local is already True).

    1. Change Copy Local = True to Copy Local = False
    2. Change Copy Local Back to True
    3. Notice in the .csproj file a True is added.
    4. Compile now and you will see the dll does indeed get included even though the message remains the same.

    Solution2: Add the True property manually.

    Conclusions: My understanding of is it is the Copy Local so if Copy Local = True the Private property should be added, but in our case at least it was not.

    Additional Considerations:

    1. Tested using Visual Studio 2013 and 2015.
    2. Tested using msbuild 12 and 14.
    3. Tested using TFS build Template.
    4. Our code has been upgraded from 2008 to 2015 visual studio, the flag may have gotten messed up somewhere in that time, but the issue did not start until the assembly was added to the GAC somehow.

    End Result:

    
    False
     packages\Microsoft.AspNet.Mvc.4.0.40804.0\lib\net40\System.Web.Mvc.dll        
            True
        
    

提交回复
热议问题