error MSB3073: How do I fix this? - c++

3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command "copy "C:\Users\jlee\Desktop\10_IPG2.7_4\InitialPowerGadget\Release\EnergyLib.dll" "C:\Users\jlee\Desktop\10_IPG2.7_4\InitialPowerGadget\Bins32\EnergyLib32.dll"
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: copy "C:\Users\jlee\Desktop\10_IPG2.7_4\InitialPowerGadget\EnergyDriver\objfre_win7_x86\i386\EnergyDriver.sys" "C:\Users\jlee\Desktop\10_IPG2.7_4\InitialPowerGadget\Bins32"
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code 1.
I was researching online, I think it has to do something with relative pathing; but I'm not sure. Can someone help explain what is wrong and how to fix this?

For anyone else that comes across this question my problem was that the target directory contained spaces i.e.
C:\Users\Administrator\Documents\Visual Studio 2017\projects\blah
So for me the solution was to wrap $(TargetDir) in double quotes i.e.
copy ..\resources\\* "$(TargetDir)" /Y

In my case the problem was that VC++ was trying to copy a .dll file into a system folder. Running it as administrator fixed the problem.

I had the following situation:
I was trying to overwrite write-protected files with an post-build event copy. I need some time to find it out because I copied various files, some were copied with success some not. But for all events an error was displayed. In the example below copy event 4, 5 and 6 failed which was indicated before the error with "Zugriff verweigert" (engl.: access denied):

Get it. I have set up a post build event to run the unit tests automatically after each build. Delete this configure, can solve this.

Just add your user to permission for cmd.exe file in system32.
that will solve this problem.

Related

Error on loading an existing project in Visual Studio 2008

When trying to load an existing project on Visual Studio 2008 Service Pack 1 I get the following error
The following error has occurred during XML parsing:
File: C:\pathTo.vcproj
Line: 49501
Column: 6
Error Message:
System error: -2147154682
The line where it fails is on a moc file that doesn't exists because as a moc file it will get generated during the build. The weird thing is that there are several moc files in other projects but not all of them fail to load only certain ones.
Thanks to Anon Mail's comment, I figured out what was needed.
I am not providing a full explanation of the answer because I don't fully understand the black magic behind it but here's what I did to fix my problem:
Make a copy of the incriminated .vcproj file :)
Manually change the .vcproj file and remove all the files (in my case all the mocs) that fails to load as Anon Mail suggested.
The project should then be loaded correctly
Once loaded close Visual Studio and restore the previous .vcproj file
Open up your solution and it should be fine.
Again, I don't really understand why it works this way but I hope this may help someone else in the future.

MSBuild - Cannot open include file (despite listed in the INCLUDE list )

I am probably missing something obvious - but I have been stuck for a while on this issue. I am compiling a Visual Studio project on the command line using MSBuild. Basically like this:
CALL vcvars32.bat
MSBuild myproject.sln /m /t:rebuild /p:Configuration=Release /verbosity:m
But this gives me an error: fatal error C1083: Cannot open include file 'winsock.h': No such file or directory
But if I check the environment variable INCLUDEafter the vcvars32.bat call the directory containing 'winsock.h' is in the list - so I definitely have this file in the SDK.
In addition if I change verbosity of MSBuild to detailed I can see the full compile command used. If I copy that and run it in the console the same cpp file compiles without any problem.
Any idea whats different inside the MSBuild context ?
Solved it, adding /p:useenv=true make MSBuild use the INCLUDE environment variable.
( Still a bit unsure why that had to be done though, since I can't recall having needed that earlier for command line builds. )

How do I resolve error MSB6006: "cmd.exe" exited with code 3?

I am getting the following error when building my code:
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error
MSB6006: "cmd.exe" exited with code 3.
Done executing task "CustomBuild" -- FAILED. (TaskId:40)
How do I resolve this?
Open your .vcxproj file as a .xml file (so with Notepad++ or equivalent.)
You should be able to search the file for the "CustomBuild" tag.
Something in the task defined by that tag is failing.
You can test what it is by trying to run the commands in that task from the command line in the same directory as the .vcxproj.
If you can't solve your problem from there I'd recommend adding the "CustomBuild" task to the question so we can better help you.
I met the same error, then I tried a lot of things, but nothing worked. Finally I removed the project, created the new one, and added the previous files to it. The problem was solved. I compared the old and new projects,found that the old project's [Qt Project Settings] and other related functions were not available, while the new project was normal.

Post-Build script throws error in VIsual Studio 2010

I've seen several threads with the same issue, but none of the solutions seems to work for me so I'm trying it here.
I need a post-build script in VS2010 that moves a .lib file to a directroy (which possibly dosn't exist yet; if so create it).
I am using this, which returns error code 2:
xcopy /y "$(TargetDir)$(ProjectName).lib" "$(SolutionDir)lib\$(ProjectName).lib"
Also tried, which returns error code 1: (what is the difference?)
copy /y "$(TargetDir)$(ProjectName).lib" "$(SolutionDir)lib\$(ProjectName).lib"
The most common issues people seem to hav is the lack of quotes on paths, but I have that.
Why dosn't it work?
This ought to be closer:
if not exist "$(SolutionDir)lib" md "$(SolutionDir)lib"
xcopy /y /d "$(TargetPath)" "$(SolutionDir)lib"
After a quick test on the command line what's happening with copy is it is failing because the directory does not exist. What is happening with xcopy is it is failing when it prompts for whether the target is a file or directory when it finds the directory doesn't exist. /-Y may be set in your COPYCMD environment variable or your target path may be misleading causing a prompt for whether the target is a directory or file which is not supressed by the /Y flag for overwrite.
Example: xcopy /Y "C:\test.txt" "missingdirectory\test5.txt"
Obviously the easiest solution is to check if the directory exists and create it if it's missing before doing the copy in your post-build script.

CPP unit build error in VS 2010

I am builidng CPPunit 1.12.1 using VS 2010. I able to build CPP unit successfully on VS 2008. I am building only CPPUnit library.
I am getting following error. How can i fix this error.
error MSB3073: The command "copy "D:\src\cppunit\.\Debug\cppunit.lib" ..\..\lib\cppunit.lib
:VCEnd" exited with code 1. C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets 113 6 cppunit
I am also mentioning one of warnings which is related to error i think so.
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(1151,5): warning MSB8012: TargetPath(D:\src\cppunit\.\Debug\cppunit.lib) does not match the Library's OutputFile property value (D:\src\cppunit\Debug\cppunitd.lib). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
These are post-build event errors.
Right click on your project-name in Visual Studio Solution Explorer:
Properties >> Post-Build Event
Remove the text from CommandLine textbox if you don't want post-build events. Or fix the path!
The issue is that the post-build step is something like: copy "$(TargetPath)" ....\lib\$(TargetName).lib.
Since the 'TargetName' value changes depending upon the build type, go in the project properties and change the 'target name' depending upon the selected build. In your case, if you check your 'warning' carefully, you will find that you are trying to copy the cppunit.lib to the ..\lib folder when actually your expected output is supposed to be cppunitd.lib. TargetName mismatch!
Another thing that I found helpful (it may be something only I observed) was building the 'release' build first, followed by the 'debug' build.
You have the configuration slightly messed up.
You are telling MSVC to create an output file in one directory and then use it from a different one - and it looks like at least one of the dirs doesn't exist.
It's nothign to do with cppunit