MSBuild is not copying the assembly to the output directory.

For some reason, when I compile projects using MSBuild, it occassionally fails to copy an assembly to the output directory. No errors occur, the assembly is built correctly to the obj directory, and compiling the project a second time using MSBuild seems to work fine.

The MSBuild output seems to indicate that the file was copied without any problems, however, the file is not in the output directory. I had the same problems with using VS from the command line (not surprising of course).

Any suggestions We have over 200 projects. Having to compile multiple times to get a project to compile correctly is not a realistic alternative.

I can include the code we use to call MSBuild, the error log, or the project that's failing (though it seems to randomly pick projects to fail).


Answer this question

MSBuild is not copying the assembly to the output directory.

  • Gary Yukish

    Alternatively delete the projectfile.proj.filelist.txt for each project prior to each build from the commandline.
  • Alaa_fcis

    "...the workaround is to use the same string value of the output path (case-insensitive of course) between builds. "

    Will VS 2005 SP1 fix this

    We use contextful builds, so a project builds differently depending on if it is the parent or an included build... of course, we want the all the output to go to the same place, so we set a property on the command-line to retarget it...


  • aprenot

    I've been building some projects in four different build configurations: Pre-Debug|Any CPU, Pre-Release|Any CPU, Debug|Any CPU, Release|Any CPU because of build dependency issues and I haven't seen this problem until I started deleting all the files under the obj folders for these projects. I think the reason the IncrementalClean target started being called seemingly randomly is that the projectfile.proj.filelist.txt files are being deleted. I'm going to try only deleting *.dll and *.pdb files from the obj folders and see what happens.



  • TopTN

    I am having similiar problems. For some reason, I only notice it in projects consisting entirely of NUnit test cases. A secondary dependency is not added to the output directory, even if I add a reference to that project myself.

  • Michael_DV

    Brian and I discussed this over email, and discovered that this is due to the fact that OutputPath is being overridden during the build, and becuase of a bug in the IncrementalClean logic.

    IncrementalClean is a target that is used to ensure that outputs that were produced in the last build, but were not produced in the current build are cleaned out.  The list of files that are produced in the last build is stored in a file under obj\debug or obj\release.

    So, in this case, what's happening is that between two subsequent builds, a different representation of the same output path is used - for instance, c:\abc\def in one case, and ..\abc\def in another case - and IncrementalClean mistakenly deletes outputs that were just produced.

    We have a bug tracking this and will be fixed in a future release - but in case anyone else runs into this issue - the workaround is to use the same string value of the output path (case-insensitive of course) between builds.  We believe that this should not be too widespread an issue - especially on developer desktops where you usually don't override the output path - but just useful to be aware of just in case.

    Faisal Mohamood | Program Manager | Visual Studio - MSBuild


  • doomgaze

    Hmm, This does not seem to be the case in our situation. The output of MSBuild shows that the files are not copied, and even on a clean build they are not copied. Only when using VS are they copied.
    I double checked that deleting the filelist files did not resolve the issue and that nothing has customized anything regarding OutputPath

  • JCampos

    Brian,

    This is the first time I have heard of anything like this.  What types of projects are these   Do you always see the issue with a specific set of projects, or a specific project type

    The build should be reliable.  You should not have to build more than once to get the code to compile and build correctly.  Sorry for the inconvenience.

    Any chance you will be able to generate a diagnostic build log for a failing scenario   You can send it to my attention at msbuild@microsoft.com, and refer to this discussion.

    Faisal Mohamood | Program Manager - MSBuild


  • MSBuild is not copying the assembly to the output directory.