Msbuild command line: MSB3021 error in CopyWebApplicationLegacy task - msbuild

I've seen several questions on here about this error, but all of them seem to be related to the "Access is Denied" flavor of this error, can't find any that deal with the message I'm getting:
C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets(177,5): error MSB3021: Unable to copy file "bin\MyApp.MyLib.dll" to "C:\Temp\Publish\staging\MyApp\MyApp_1478_5\bin\MyApp.MyLib.dll". Could not find a part of the path 'bin\MyApp.MyLib.dll'. [C:\Temp\Tags\MyApp\2011-10-27-00-NoBuildVs\src\MyApp.com\MyAppn.csproj]
I get 30 of these errors when I build my proj. I'm building my csproj file from the command line. The proj compiles fine, it's only when it gets to the CopyWebApplicationLegacy task that things screw up. The odd thing: the app runs fine and the dlls that it is trying to copy are present in the target dir in the end. So these errors seem to have no bearing on whether the files end up where they should be or whether the app will behave correctly.
I'd consider just suppressing them, but that seems like it'll bite me later.
My command:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe "C:\Temp\Tags\MyApp\2011-10-27-00-NoBuildVs\src\MyApp.com\MyApp.csproj" /p:OutDir="C:\Temp\Publish\binOutput\" /p:WebProjectOutputDir="C:\Temp\Publish\staging\MyApp\MyApp_1478" /p:Configuration=Debug
Tried building the solution instead of the csproj and that got the same error.
I'm stumped here. The files aren't being locked (unless they are being locked during the build somehow and released later, but it seems like I'd get a different error). What could be causing this error? I need to get this going so my automated publish can work.

What I see from the error log: source file "bin\Debug\MyApp.MyLib.dll" should be used instead of "bin\MyApp.MyLib.dll" for Debug configuration, IMO.

Related

VS2012 Compiler randomly tells that output file can't be written

I am compiling a bigger VB.NET project using VS2012.
Randomly, but very often after having run my project in Debug Mode, I get the error
"The output file <mypathhere> could not be written. Permission denied."
I have also tried using MSBUILD to give me more details about this error, but it didn't help.
Also, I have tried disabling the Hosting option because I thought that this might be the cause, but it wasn't.
I used ProcessExplorer to find out which process might have locked my file, but it didn't show anything.
Does anybody have any more ideas?
When I try to set the application's output folder to not-writeprotected using the Windows properties dialog, I get the "Changing attributes denied. Permission denied." error on the output file.
Thank you very much!
There are a couple of reasons why this could happen
An instance of your program is currently running hence Visual Studio can't write over the file. Next time this happens check and see if any instances of your program are running in task manager.
An anti-virus program has a lock on your file to analyze it and prevents VS from overwriting it. Try excluding your project director from analysis and see if the problem dissapears
The solution is to activate the Application Experience service in Windows. This is a known MS bug.

msbuild failing with "cannot find a a part of the path"

I'm running msbuild on my .sln file and I'm suddenly getting
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2291,5):
error SB3554: Cannot write to the output file "C:\Work\product\src\component\
obj\Debug\product.resources". Could not find a part of the path 'C:\Work\
product\src\component\obj\Debug\component.Resources.resources'. [C:\Work\
product\src\component\component.vbproj]
No amount of deleting binaries and retrying helps
Had a similar intermittent problem, added these options to the copy command
Retries="10" RetryDelayMilliseconds="5000"
and it seemed to do the trick
The error states product.resources is failing because component.Resources.resources cannot be found.
Ensure your project build order is correct since resources files are built at compile time and it cannot find the needed resources file to continue.
Another solution you might try is to delete and re-add any .resx files in your projects.
Also, I would create one shared project with resources for the solution to make it easier to mange your resources. Here is an example although a little dated.
How to use shared resource file between projects in one solution?
MSDOCS-Packaging and Deploying Resources in .NET Apps

Team Foundation Server build is transforming web.config TWICE, and the second time is wrong

I have a TFS build definition set up with the following information in the Process -> Advanced -> MSBuild Arguments section: (the [] bracketed values are omitted in this post for security)
/p:DeployOnBuild=True
/p:MSDeployPublishMethod=RemoteAgent
/p:MSDeployServiceUrl=[URL]
/p:DeployIisAppPath=[IISPATH]
/p:UserName=[USERNAME]
/p:Password=[PASSWORD]
/p:CreatePackageOnPublish=True
/p:DeployTarget=MSDeployPublish
/p:Configuration=Development
Here's the issue I have. I have many configurations set up in my web project, and the Development configuration is one of them. If I leave off the "/p:Configuration=Development" and build the project, which then auto-deploys to our dev environment, the web.config transform is wrong. It's replacing my connection string info with the information from another configuration.
If I put the "/p:Configuration=Development" back into the MSBuild arg list and open the web.config file in VS2010 during the build process, the first time the web.config is changed outside my IDE, I can see that the appropriate web.config transform has been made in accordance with the Development configuration, but then the web.config file is changed AGAIN, and it's back to the improper configuration.
My thought here is that when leaving the "/p:Configuration=Development" on, MSBuild is getting it right, but whatever process that is called from MSBuild (I'm assuming MSDeploy) to actually deploy the site to the server is getting it wrong.
Oh, and I'm using an IIS6 server, not IIS7, so any IIS7-specific functionality won't really help me.
Any ideas here of how to fix this problem?
EDIT - Fix
So, some colleagues and I spent some time on this and eventually rebuilt our environments for an unrelated reason. After rebuilding, we started to see the same thing happening. We took a look at the IIS Temporary Compressed Files (C:\inetpub\temp\IIS Temporary Compressed Files) folder and noticed a lot of old info being stored. We deleted everything from that folder and ran iisreset, and the build worked as expected.
-- Original Post
I am having the exact same issue. I have looked at every output file I can think of on the build server and they are all correct. However, when msdeploy is called, the transform seems to happen (based on modified date) but is done wrong. I have also tried grabbing the deployment.zip and importing application on the web sever, which does deploy correctly. Does anyone know how to intercept the msdeploy call from the build server to see what exactly the command contains. I have tried procmon, but not having much luck.

MSBuild ResolveProjectReferences Error

My MSBuild build script executes fine on all the development machines, but fails to run on the build server, except for the Trunk build. Branches all fail with the following warnings indicating the source of the problem:
Target "ResolveProjectReferences":
C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets (0,0):
warning : The referenced project '..\..\..\Class Library\
Company.BusinessModel\Company.BusinessModel.csproj' does not exist.
I can't understand why this error is even appearing - I have verified that (relative to the csproj being processed) the referenced project does exist. Copying (file copy) the checked out code to my local machine and running the script, the build completes as expected.
Is there anything obviously wrong here? Anything I can check to try and resolve this mystery?
EDIT:
I've tried running MSBuild against the project raising the build error in isolation, so it's not the rest of the solution which is the problem, just something about this specific .csproj file.
I actually found the problem. It's a bug in Visual Studio 2010 with path names totalling 259
http://support.microsoft.com/kb/2516078
Have you run msbuild in diag mode. That should give you some hints about the current path, and the relative path that MSBuild is trying to search.
msbuild myproj.msbuild /v:diag

cannot access because it is used from another process

Well suddenly when I’m trying to run my project from the debugger in Visual Studio 2010 It gives me this error:
Error 40 Unable to copy file "obj\x86\Debug\AssetsManagement.exe" to "bin\Debug\AssetsManagement.exe". The process cannot access the file 'bin\Debug\AssetsManagement.exe' because it is being used by another process.
Please is there someone how knows why that happens?
I have already delete the x86\Debug subfolder and te bin\Debug subfolder but nothing happen
Especially in the second folder the only file which cannot deleted was the the .exe file Also with the same error.
Most of the time when I see this error I go look in task manager and I see a VSHost file for my project running. You can't kill it, it just comes back. It's gotten to the point now I always uncheck enable visual studio hosting on the debug tab when I start a new project.
Try commenting out AssemblyVersion in AssemblyInfo.vb and performing a build.
Assembly: AssemblyVersion("1.0.0.0")
This has worked for me.