Running MSBuild from command prompt with OpenCV - visual-studio-2010

I want to create a batch file that builds several Visual Studio 2010 projects. My project property sheet is setup to use opencv, and building from Visual Studio works fine, but when I run the MSBuild command from cmd, it doesn't find the OpenCV header files. I get many of the following messages:
c:\proj\libproj\cvtrack.cpp(26): fatal error C1083: Cannot open include file: 'cv.h': No such file or directory [C:\proj\libproj\libproj.vcxproj]
Any ideas?

I fixed this by adding the following parameter to the MSBuild command, /p:Configuration=Release
, and then changein the project's Release properties.

Related

Build Visual Studio C++ project/solution from command line

I am trying to compile a Visual Studio 2019 project or solution using msbuild. But when I'm running a command, an error pops up in the command line
MSBUILD : error MSB1009: Project file does not exist.
Key: TestProject.sln
Here code that im using in .bat file:
set pathMSBuild = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\"
#echo off
cls
cd %pathMSBuild%
msbuild C:\TestProject\TestProject\TestProject.sln
pause
I don't understand why this is happening because I have specified the correct path to the project on the disk and I have it there. Any ideas why its happens?

How to build and run Xamarin.UWP application from command line?

How do I build and run a Xamarin.UWP application from the command line? I want it to be so that the app builds and runs the same way as the green run button in the Visual Studio 2019 GUI.
Additional notes:
I've tried opening the Visual Studio Developer Command Prompt and trying the following implementations.
msbuild -t:build "PATH_TO_PROJECT\SimTools.UWP.csproj"
Although when I run the executable that gets generated, it gives me this error:
as well as
Additionally, I've tried doing
msbuild -t:build "PATH_TO_PROJECT\SimTools.UWP.csproj" && msbuild -t:install "PATH_TO_PROJECT\SimTools.UWP.csproj"
And although it builds successfully, it says that there is no target for "install" and I do not know how to add that to the .csproj file as I've asked over at How do I add an "install" target to a Xamarin.UWP .csproj file?.

Visual Studio 2017 fails to build project using msbuild

I am trying to build this project which generates a minified css file for my website, I moved the project files to a new PC with a new version of Visual Studio (2017 from 2010) and after some small issues I got solved, I am now feeling stumped. This is the error:
Error The command "C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe
"C:\Users\Dennis\Documents\Visual Studio
2017\Projects\minify-CSS\minify-CSS\MSbuild\msbuild.xml"
/p:ConfigurationName=Release" exited with code 9009.
I know the error is in the path, there's a space in the path and there's no citation marks around the path. I don't know why VS2017 fails at this. I navigated to the msbuild folder in the command prompt and ran the build command manually, the project compiled just fine. Anyone know where I can correct this so the path is put in citation marks, or otherwise get around this?
I got it to work. I opened the project file and found this line:
<PostBuildEvent>$(MSBuildBinPath)\msbuild.exe "$(ProjectDir)MSbuild\msbuild.xml" /p:ConfigurationName=$(ConfigurationName)</PostBuildEvent>
I just added citation marks around the first part and it started working. Like this
<PostBuildEvent>"$(MSBuildBinPath)\msbuild.exe" "$(ProjectDir)MSbuild\msbuild.xml" /p:ConfigurationName=$(ConfigurationName)</PostBuildEvent>

Project paths in a Visual Studio Solution via Environment Variable and msbuild

I use syntax like "%SDK_PATH%\sdk_dir\test.vcxproj" in .sln file.
And it is work fine for me from IDE.
But msbuildl does not understand this syntax and will emit a error MSB3202 ("The project file was not found.") when I use it from command line:
msbuild test.sln /p:Configuration=Debug
Is there a way to resolve this issue?

error MSB4057: The target "v8" does not exist in the project

I'm trying to build V8 as part of ArangoDB using the official build scripts and following the official Windows build instructions.
The compilation fails for all v8* targets (v8-build.bat):
msbuild All.sln /t:v8 /p:Configuration=Release /p:Platform=x64
msbuild All.sln /t:v8_libbase /p:Configuration=Release /p:Platform=x64
msbuild All.sln /t:v8_libplatform /p:Configuration=Release /p:Platform=x64
error MSB4057: The target "v8" does not exist in the project.
If I open the solution file in Visual Studio, it looks like this:
I can build v8, v8_libbase and v8_libplatform just fine in VS.
Windows 7 64bit
Visual Studio 2013 Ultimate
Cygwin 2.2.0
cmake 3.3.1
You can run
set MSBuildEmitSolution=1
msbuild All.sln /t:v8
Then search in the generated All.sln.metaproj file the exact target names (<Target Name="">) of all projects you want to build. v8 can have a name like _tools_\_gyp_\v8. After that you can build projects
msbuild All.sln /t:"_tools_\_gyp_\v8" /p:Configuration=Release /p:Platform=x64
The correct way to specify a target/project if it's in a solution folder is:
msbuild all.sln /t:PATH\TO\PROJECT
But in case of (tools) and (gyp) it's simply not possible, because msbuild can't handle parentheses in the target parameter /t.
So either remove ( ) and specify the path like tools\gyp\v8, or get rid of the solution folders entirely. If the solution is flat, /t:v8 will work.
Unfortunately, both the wrapping of folder names with brackets as well as the generation of non-flat .sln are hardcoded in gyp, which generated my all.sln. There is no switch to control whether solution folders are created or not. It will create them if the target version of Visual Studio is known to support this kind of nesting.
Workaround: Force flat solution generation in gyp, see
https://github.com/arangodb/arangodb/commit/796d2d263db6271142d954c8c99b9dec0fbe75e9
Reported errors to Microsoft/msbuild and Google/gyp:
https://github.com/Microsoft/msbuild/issues/157
https://code.google.com/p/gyp/issues/detail?id=494
#dothebart and this post helped me a lot to figure it out, thank you!
In VS2013 use
msbuild All.sln /p:Project=v8;Configuration=Release;Platform=x64

Resources