Postbuild step not working in VS2017 - visual-studio-2017

I have a VS2017 solution and I'm trying to copy an external DLL into the same folder as the final .exe executable (whether it will be Debug, Release or Publish)
tried with:
xcopy "$(ProjectDir)..\..\myDllFolder\myDll.dll" $(ProjectDir)$(OutDir)
I get:
Severity Code Description Project File Line Suppression State
Error MSB3073 The command "xcopy
"C:\Projects\Reviewer\Eurotherm.Reviewer\Eurotherm.Reviewer.ServiceHost\....\LMBrick\LMBrick.dll"
C:\Projects\Reviewer\Eurotherm.Reviewer\Eurotherm.Reviewer.ServiceHost\bin\Release\net461\
/i xcopy
"C:\Projects\Reviewer\Eurotherm.Reviewer\Eurotherm.Reviewer.ServiceHost\....\LMBrick\LMBrickX.dll"
C:\Projects\Reviewer\Eurotherm.Reviewer\Eurotherm.Reviewer.ServiceHost\bin\Release\net461\
/i" exited with code
2. Eurotherm.Reviewer.ServiceHost C:\Projects\Reviewer\Eurotherm.Reviewer\Eurotherm.Reviewer.ServiceHost\Eurotherm.Reviewer.ServiceHost.csproj 48
xcopy exited with code 2
The directories are present, the input file is present. why it doesn't work? Code 2 means xcopy doesn't know if the second parameter is a folder or a file, I tried forcing the answer using /i but I get the same error

Related

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. )

c1010070: Failed to load and parse the manifest

I have an existing wxWidgets project which I am trying to compile under Visual Studio 2010 (the project was created probably with older version of Visual Studio - could be even VS2003). I compiled wxWidgets library (also included paths in my project). When compiling my project now, I get this error:
1>------ Build started: Project: Terminals, Configuration: Debug Win32 ------
1>Build started 8/24/2015 10:56:23 AM.
1>InitializeBuildStatus:
1> Touching "Debug\Terminals.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1>ResourceCompile:
1> All outputs are up-to-date.
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>Link:
1> All outputs are up-to-date.
1>Manifest:
1>
1>wx\msw\wx.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the path specified.
1>
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.59
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Can someone help?
This happens if your project's path has a space in it, for example in my case the project is within my Windows account, so the path begins with "C:\Users\Adam Reece...". I then get "C:\Users\Adam" within a "cannot find" like error when building the manifest.
This is 100% a bug with Visual Studio recently of which Microsoft refuses to recognise. You are not in the wrong for having a space in your path as it's been supported since Windows 95. However as a workaround you either need to make sure there are no spaces in the full path to your project, or disable generation of the manifest. (Project properties -> Linker -> Manifest File -> Generate Manifest -> Change to No (/MANIFEST:NO).)
Based on your description, I suggest you to validate your manifest file and make sure it is correct. You can use Manifestchk.vbs or “ mt.exe -manifest 1.manifest -validate_manifest “.
Moreover, from your error message, you need make sure the complier can find your manifest file configure your configuration correctly.
Go to “Configuration Properties -> Linker -> Manifest File”; turn the
“Generate Manifest” to “No”.
Go to “Configuration Properties -> Manifest Tool “; add your manifest
file path, like: (give mainfest file name like “f:/xxxx.manifest”) to
“Additional Manifest Files”; and turn the “Embed Manifest” to “No”.
Eventually, rebuild again.
If you have any more questions, please feel free to let me know.
This error message always happen when Visual Studio could not find the file. There are some potential causes:
Numbers or spaces in the project name
Project name too long
Started creating the project from a blank project that doesn't have
all of the parts.
I'd suggest trying each of the following to see if it fixes the issue- but backup your project/solution directory first.
A) Clean and rebuild the solution
B) Right click on the solution for the project (in Solution Explorer) and rename the solution to a very simple name (e.g., soln). Then do the same for the project (e.g., rename to proj). Do a rebuild all and see if the problem goes away. If it does you can rename the solution and project to something more meaningful.
C) Right click on the project and open it's properties. Go To Link | Manifest and turn off use of the manifest. Rebuild.
D) Create a new Win32 console project. Have Visual Studio create the initial CPP and .H files you need. Open your old source files and copy the code from those into the new files. Rebuild the new project.
I had the same problem and found the solution that DOES NOT require creating a new user profile...
Yes, it is caused by spaces in usernames. But why? Because mt.exe uses TEMP/TMP environment variables. On one of my machines, the username was with the old 8.3 format in TEMP (C:\users\gerson~1) and that worked. This gave me a hint as to how to adress the problem:
set your users' TEMP to some folder that has no spaces
set your users' TMP to some folder that has no spaces
Ensure you restart VS so that the settings changes take effect. Your build should work now ;)
I had this error together with msb3073. I solved the issue by modifying the project's vcxproj file, changing from:
<PostBuildEvent>
<Command>mt.exe -manifest DesignedForWindows7.manifest -i [...]
</Command>
</PostBuildEvent>
to
<AfterBuildEvent>
<Command>mt.exe -manifest DesignedForWindows7.manifest -i [...]
</Command>
</AfterBuildEvent>
where, in place of [...], there is some command line code that I just copied-pasted.
Be careful that there might be more than one such code block in the vcxproj file
UPDATE 02/07/21: Found a solution for Win10.0..... SDK
https://stackoverflow.com/a/49276285/16360714
I got c1010070: Failed to load and parse the manifest
because my Windows User Profile had a space in it e.g. C:\Users\ John Doe\ and I was trying to use UE4 with C++ and Visual Studio 2017, Win 8.1 SDK
FINAL SOLUTION AT END
Solution 0: CHange TMP and TEMP Windows environment variables to folders with no space. This could break other programs. I kept it changed though while trying other solutions.
Solution 1: Exclude C\User\John Doe ... folders from the project
Solution 2: Try to change your Windows Profile Folder Name (tutorials on YouTube)
Solution 3: Create a new Windows local account with no whitespace and use it for dev
Solution 1 Explanation
If you are using UE4, Makefile will be your Project Configuration default. So you won't have access to Linker or Manifest Tool Settings.
I was getting the following errors when building:
Severity Code Description Project File Line Suppression State
Error c1010070 Failed to load and parse the manifest. The system cannot find the file specified. VirtuPilotv3 C:\Users\John
Severity Code Description Project File Line Suppression State
Error LNK1327 failure during running mt.exe VirtuPilotv3 K:\VRDEVELOPMENT\Virtu-Pilot\Intermediate\ProjectFiles\LINK 1
1
Severity Code Description Project File Line Suppression State
Error MSB3073 The command "K:\VRDEVELOPMENT\UE_4.26\Engine\Build\BatchFiles\Build.bat VirtuPilotv3Editor Win64 Development -Project="K:\VRDEVELOPMENT\Virtu-Pilot\VirtuPilotv3.uproject" -WaitMutex -FromMsBuild" exited with code 6. VirtuPilotv3 C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets 44
I noticed the Macro $(PATH) in Property Page>General>Executable Directories contained a C:\ Users folder path "C:\Users\John Doe.dotnet\tools" to be specific.
So I added the .dotnet folder to my exclude directories and BINGO! I could build and open the editor. [1 VISUAL STUDIO WARNING]
Discovered C:\Users\John Doe.dotnet\tools is found under Windows "path"Environment Path Variables Image variable
I'll probably make a copy of the .dotnet folder to something like C:\VisualStudioCustom and add that folder as Windows Path New .dotnet folder set as path. This Should Solve the problem for all projects. As the new folder will automatically get added to Visual Studios Macro $(PATH). [IT ACTUALLY WORKED, NO VS ERRORS]

error MSB3073: How do I fix this?

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.

Building Tesseract in Visual C++ 2010

When I try to build the Tesseract solution in Visual C++ 2010 Express it's saying:
21>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command "post-build.cmd "C:\Tesseract-OCR\tesseract-3.01\vs2010\Release\" "C:\Tesseract-OCR\tesseract-3.01\vs2010\bin.rel"
21>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code 4.
========== Build: 20 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I don't know how to proceed. Does anyone know what the problem is and how I can solve it?
You have to edit post-build.cmd file in [tesseract source]\vs2010 folder as follows
Open the file, in Notepad++ for example, and "rem" the following lines:
xcopy ..\vs2008\lib\liblept168%DebugVersion%.dll %TargetFolder% /Y /I /D
rem copy data
if not exist %DataFolder% (
md %DataFolder%
)
xcopy ..\TessData\eng.traineddata %DataFolder% /Y /I /D
This should do it, if you have installed the executables previously. Since tesseract gets the \tessdata\ folder from environmental variable (TESSDATA_PREFIX) in "mainblk.cpp" file in main_setup function there is no need to copy data folder as instructed in post-build.cmd.
If you didn't install the executables then you have to create this variable manually. the value should indicate the folder where \tessdata\ resides no the \tessdata\ itself since in the last line of main_setup \tessdata is added to the path.
run vs2010 as administrator and build again as raym0nd has suggested. It worked for me.
You probably didn't install tesseract-ocr-3.01.eng.tar.gz properly.
From their readme:
Download these packages:
tesseract-3.01.tar.gz - tesseract source
tesseract-3.01-win_vs.zip - Visual studio (2008 & 2010) solution with
necessary libraries
tesseract-ocr-3.01.eng.tar.gz - English language file for tesseract
(or download other 3.01 or 3.00 language datafile)
Unpack them to one directory ('tesseract-3.01').
tesseract-ocr-3.01.eng.tar.gz has wrong name of root directory
('tesseract-ocr' instead of 'tesseract-3.01'). Windows relevant files
are located in vs2008 directory (e.g. 'tesseract-3.01\vs2008'). The
same build process as usual applies: Open tesseract.sln with
VC++Express 2008 and build all (or just Tesseract) It should compile
(in at least release mode) without having to install anything further.
The dll dependencies and Leptonica are included. Output will be in
tesseract-3.01\vs2008\bin (or tesseract-3.01\vs2008\bin.rd or
tesseract-3.01\vs2008\bin.dbg based on configuration build).

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.