Run a solution from Visual Studio console without opening the IDE - visual-studio-2010

I am using Visual Studio 2010 SP1.
What I first tried was this:
Open the Visual Studio console tool from start menu
Navigate to project folder (which already contains an executable)
Run: msbuild myproject.sln or msbuild myproject.sln /p:Configuration=Release
This builds successfully, but I can't find an executable to run
The second thing I tried was steps 1 and 2 from above
Running: devenv myproject.sln /Build and devenv myproject.sln /Run
This somewhat works but it seems to open the IDE to run the build
The whole point was to avoid using the ide at all.
Now, how do I build and run a solution without opening the IDE?
--------------------------FIXED------------------------------
The problem was that I was looking in the wrong place for the executable (noob mistake). I ended up using this batch file:
msbuild myproj.sln /p:configuration=Release
cd (("Path to executable" usually in the Debug/Release Folder))
myExecutableName
cd (("Path to original folder"))

Navigate to your solution folder
Run: msbuild myproject.sln /p:Configuration=Release (or Debug)
cd myproject (within your solution folder - it's a sub-folder)
cd bin
cd Release (or Debug)
Run: myproject.exe
You can replace the three separate cd commands with a single one:
cd myproject\bin\Release
Or simply run your executable from the solution folder:
myproject\bin\Release\myproject.exe

Related

command line solution build using devenv rebuilding more projects than visual studio solution build

I am trying to mimic visual studio solution build from command prompt using batch script but there is significant difference between manual solution build(ctrl+shift+b) inside visual studio and command line solution build using devenv in terms of project rebuild counts. More projects are getting rebuilt from command line in comparison to visual studio solution build.
I am using this for command line build in batch file:
call"C:\ProgramFiles(x86)\MicrosoftVisualStudio\2019\Professional\VC\Auxiliary\Build\vcvars32.bat"
devenv solution_name.sln /build "Debug"
command line solution build output looks like this: devenv solution build using cmd prompt
visual studio solution build output looks like this: manual vs solution build output
I have tried changing the configurations too but it didn't help, I am curious why this might be happening and is there a way to get same result from command line build as of manual vs solution build?

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

Unable to specify project of solution for MSBuild

I have the following solution:
MySolution\
MySolution.sln
MyCSProject\
MyCSProject.csproj
MyCPPProject\
VC11\
projfile.vcxproj
VC8
projfile.vcproj
MyInstallationProject
MyInstallationPackage.vdproj
In Visual Studio I have MyCSProject set as main project. But for automated build I need to build MyInstallationProject with dependencies. MyInstallationProject depends on MyCSProject and MyCSProject depends on MyCPPProject. If I build from Visual Studio, it works.
But for MSBuild I can't compose correct command. Neither of the following worked:
"...\MSBuild.exe" MySolution.sln /t:MySolution\MyInstallationProject /p:Configuration="Release" /p:Platform="x64"
"...\MSBuild.exe" MySolution.sln /t:MySolution\MyInstallationProject.vdproj /p:Configuration="Release" /p:Platform="x64"
"...\MSBuild.exe" MySolution.sln /t:MyInstallationProject /p:Configuration="Release" /p:Platform="x64"
"...\MSBuild.exe" MyInstallationProject\MyInstallationProject.vdproj /p:Configuration="Release" /p:Platform="x64"
and so on, with various errors, mainly "The target *** does not exist in the project"
How to know correct command and or the name of target, associated with the project?
In fact, one of the third and the fourth msbuild command line should have worked in your side. Also, there is a document about it.
The truth is that MSBuild cannot build the vdproj file. It is from VS installer project extension and the build tool is a separate tool from the extension rather than in the MSBuild. You can easily open the vdproj file and could find that it is not a xml style.
MSBuild can only build the xml sytle proj file.
To test it, you could try the same msbuild command line for MyCSProject project to get the difference.
So the right way is to use VS IDE build or use devenv build command line which means you have to you have VS IDE on your local.
Try the following command line:
1) open Developer Command Prompt for VS:
2) run:
cd xxx\xxx\MySolution
devenv MyInstallationProject\MyInstallationProject.vdproj /build

Leptonica on Windows + Visual Studio

I have followed the following steps for installing Leptonica on Windows with Visual Studio
3. Building on Windows
(a) Building with Visual Studio
1. Download the latest SW
(Software Network https://software-network.org/)
client from https://software-network.org/client/
2. Unpack it, add to PATH.
3. Run once to perform cmake integration:
sw setup
4. Run:
git clone [https://github.com/danbloomberg/leptonica](https://github.com/danbloomberg/leptonica)
cd leptonica
mkdir build
cd build
cmake ..
5. Build a solution (leptonica.sin) in your Visual Studio version.
I did everything except for step 5.
My build directory now looks as follows:
ALL_BUILD.vcxproj LeptonicaConfig.cmake
ALL_BUILD.vcxproj.filters LeptonicaConfig-version.cmake
cmake_install.cmake LeptonicaTargets.cmake
cmake_uninstall.cmake src/
CMakeCache.txt sw_build_dependencies.vcxproj
CMakeFiles/ sw_build_dependencies.vcxproj.filters
config_auto.h.in uninstall.vcxproj
INSTALL.vcxproj uninstall.vcxproj.filters
INSTALL.vcxproj.filters x64/
lept.pc ZERO_CHECK.vcxproj
leptonica.sln ZERO_CHECK.vcxproj.filters
I cannot seem to find leptonica.sin and how to integrate with visual studio ? I need the steps that are left. I am new to visual studio please mind my question.
I have Visual Studio 2019
You probably already figured this out (I'd hope) but if not... Step #5 as you listed has a typo:
Build a solution (leptonica.sin) in your Visual Studio version.
It's supposed to be leptonica.sLn, as in a Visual Studio Solution file.
In your build directory listing you have leptonic.sln. If you double-click that it should open in Visual Studio (assuming a default/correct install).
With Visual Studio 2019 at least you don't actually have to generate a solution file with CMake manually like this as Visual Studio now supports opening folders that contain CMakeLists.txt files as though they are solutions.
You can just do the following to build Leptonica on Windows:
Download sw-master-windows-client.zip from https://software-network.org/client/.
Unzip sw.exe to some directory sw_dir.
Add sw_dir to your path environment variable. Log out and log in to make sure the path is updated.
Enter power shell etc. and run "sw setup" from a command line.
Git clone Leptonica to some directory from https://github.com/danbloomberg/leptonica
Start up Visual Studio.
Choose "Open local folder" from the intitial dialog VS presents you with. Select the Leptonica folder.
At this point Visual Studio will begin running CMake on the folder and it should succeed assuming it can find sw.exe. This step takes a while. After it completes you can build all from the build toplevel menu.

`msbuild` command not found, but `msbuild.exe` works fine

I run MSys/Bash as distributed in Git for Windows. I added the folder C:\Windows\Microsoft.NET\Framework\v4.0.30319 to my path, so I could run msbuild but it doesn't work
$ msbuild
C:\Program Files (x86)\Git\bin\sh.exe: msbuild: command not found
Yet msbuild.exe does:
$ msbuild.exe
Microsoft (R) Build Engine version 4.0.30319.17929
Yet the command explorer resolves fine. What's going on?
It's a bug in MSys where the same name is shared by a folder and a file (minus the extension). In this case:
File C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
Folder C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild
You'll have to workaround by writing msbuild.exe
If the exe file outputs not found, do copy C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe ProjectPath
And then run msbuild.exe
If msbuild.exe cannot be found, it needs to be configured.
Open a command prompt and run the file vsvars32.bat located in your Visual Studio Common7/Tools folder..
i.e C:\Program Files x86\Microsoft Visual Studio 12.0\Common7\Tools\vsvars32.bat
This will correctly setup all the neccessary variables for msbuild.exe to be found.

Resources