MSBuild & TeamBuild - BuildInParallel failing because of MSB3021 file permission violation

前端 未结 6 2084
隐瞒了意图╮
隐瞒了意图╮ 2021-01-31 09:36

I maintain the build of a fairly large piece of software, consisting of roughly 350 csharp projects. Our build time for a debug built clocks in at about 17 minutes.

I h

6条回答
  •  攒了一身酷
    2021-01-31 09:57

    I have the same problem many months ago.

    There are two types of file copy in VS C# project files (.csproj files):

    1. Referenced Assemblies which has a "Copy Local" property. when the property is True, the assembly is copied into output path.

    2. Additional files which has a "Copy to Output Directory" property. when the property is set to "copy always" or "copy if newer" the file is copied into output path.

    problem:

    A: If two or more projects are built concurrently, and two of them tries to copy the same file into output directory, you may faced with the errors like "error MSB3021: Unable to copy file", "Access to the path is denied", "The process cannot access the file", etc.

    B: If two or more projects refrences a common project which has some items of type 2. In this case during the parallel build of the projects, two of them may tries to build the "GetCopyToOutputDirectoryItems" target of the common project concurrently. So you may again faced with the above exceptions.

    Solution1:

    force the OutputPath of different .csproj files not to be in tha same path

    http://social.msdn.microsoft.com/Forums/is/tfsbuild/thread/a62a6f98-ec44-46c1-a0d0-7f441f0db973

    solution2:

    Step1: The solution is to set the property of common Items (to False in case 1 and to "dont copy" in case 2) for all but one of these common items in your projects. or remove them If it is possible.

    In order to find potential mistakes, you can search the words "private" (for case 1) and "CopyToOutputDirectory" (for case 2) in files *.csproj

    Step2: ...

    Good Luck

提交回复
热议问题