The gtest's msvc directory has the gtest project file, and opening it with Visual Studio enables me to select the build out of 8 configurations(gtest/gtest_main/gtest_prod_test/gtest_unittest x release/debug) with Batch Build.
How can I do the same thing with msbuild tool? For example, how can I tell msbuild to build gtest/Debug or gtest_unittest/Release?
MSBuild projectfile /property:Configuration=Debug
http://msdn.microsoft.com/en-us/library/ms171452%28v=vs.80%29.aspx
Kyle Alons's answer works fine. When I run solution file that has four projects, it generates the release version of each project.
msbuild gtest-md.sln /property:Configuration=Release
I could run each project as follows, but the output names are based on solution name, so I need to modify to get correct results.
msbuild gtest-md.vcxproj /property:Configuration=Release
The solution was to specify target as follows.
msbuild gtest-md.sln /target:gtest-md /property:Configuration=Release
Related
I have Visual studio project solution which has multiple .csproj. Each .csproj has some reference libraries.The project settings are made in such a way the reference libraries are built first and then .csproj is built. This works as expected when i run it in visual studio IDE. But when i try to execute using msbuild i'm getting an error saying target doesn't exist. Gone through many posts related to this issue ,tried possible things.But didn't built.Looks like i might be doing something silly or missing something in the settings.
Also tried using devenv from commandline. With this option i dont see any error but at same time the project doesnt build.I dont see any message after execution of command.Im using visual studio 2015
Here is my project structure
Poject.sln
ProjectA
porjectB
projectC
Libraries
libA
libB
msbuild "project.sln" target:"D:\Projects\Source\Demo\ProjectA\ProjectA.csproj" /t:build
"/p:Configuration=Debug" "/p:platform=x86"
I see the below error
"D:\project.sln" (D:\Projects\Source\Demo\ProjectA\;build target) (1) ->
D:\project.sln.metaproj : error MSB4057: The target "D:\Projects\Source\Demo\ProjectA" does not exist in the project. [D:\project.sln]
Here is the command used using devenv
devenv.exe "project.sln" /build Debug /project `"D:\Projects\source\Demo\Applications\ProjectA\ProjectA.csproj" /projectconfig Debug
After executing the above its doesnt build and i dont see any error too.
error MSB4057: The target "D:\Projects\Source\Demo\ProjectA" does not
exist in the project.
The error indicates your path in command is not valid and project.sln can't recognize the path. So you actually meet one path-related issue. And you should pass the ProjectA to the targets argument instead of ProjectA.csproj! More details see tip3 in For MSBuild.
For MSBuild:
1.If you're only trying to build ProjectA and its reference libraries.
Navigate(cd) to path where ProjectA.csproj exists, and then use command msbuild ProjectA.csproj /t:build /p:Configuration=Debug /p:platform=x86
Also you can directly use command msbuild AbsolutePath\ProjectA.csproj /t:build /p:Configuration=Debug /p:platform=x86. It's not necessary to use " to cover the path and arguments.
(ProjectA.csproj file should have definitions about the reference to those two library projects, so msbuild ProjectA.csproj will build those two projects first. You don't need to specify the xx.sln in your command.)
2.If you're trying to build whole solution(all the projects):
msbuild project.sln /t:build /p:Configuration=xxx /p:platform=xxx
Navigate to solution folder when you run above command, or use absolutepath\project.sln with that command.
3.When you want to build specific projects(more than one) in solution:
Check How to: Build Specific Targets in Solutions By Using MSBuild.exe. Since you're only build ProjectA, you don't need to use this format. For example: Only when you need to build both ProjectA and ProjectB, but not build ProjectC... You can use command like:
msbuild xxx.sln /t:NotInSlnfolder:Build;NewFolder\InSolutionFolder:Build
Pay attention to the path when you use this format. Whether your project is in solution folder can affect the build result a lot ! And, the direct cause of your issue, this command's targets argument needs one ProjectName as input instead of ProjectName.csproj.
For Devenv command:
1.I always use VS2017 and VS2019,so I'm not certainly sure if VS2015's devenv related command has big difference from VS2017's or VS2019's. But according to details from this VS2017 document:
Commands that begin with devenv are handled by the devenv.com utility, which delivers output through standard system streams, such as stdout and stderr.
Alternatively, commands that begin with devenv.exe can use the same switches, but the devenv.com utility is bypassed. Using devenv.exe directly prevents output from appearing on the console.
I think that's why you don't see any message after execution of command. You should use devenv.com command to see the output in console. And it's by design that devenv.exe will prevents output from appearing on the console.
2.The following command builds the project CSharpWinApp, using the Debug project build configuration within MySolution.
devenv "%USERPROFILE%\source\repos\MySolution.sln" /build Debug /project "CSharpWinApp\CSharpWinApp.csproj" /projectconfig Debug
More details about devenv reference please check this document.
In addition:
1.Looks like you have one strange project structure. I checked your error message above and it seems your several projects(xx.csproj) are not under Solution(xx.sln) folder. Just a suggestion, the normal folder structure for VS2015 is always:
Solution folder
xx.sln
ProjectA folder
ProjectA.csproj
ProjectB folder
ProjectB.csproj
2.For most of the projects, build using msbuild is more powerful and convenient than build using devenv. So if you don't have special reason, I recommend using Msbuild, the build engine of VS.
Hope all above helps to resolve your issue and puzzle. Let me know if your issue persists:)
File "/Users/morel893/Desktop/env/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "projects_project" does not exist
LINE 1: ...ct"."technology", "projects_project"."image" FROM "projects_...
I have created InstallShield Basic MSI project from Visual Studio (IS 2012 Spring, VS 2010). My InstallShield project having 2 product configurations and each configuration having one release.
Product Configuration 1
Release 1
Product Configuration 2
Release 2
For building project in VS IDE, I need to set the corresponding product configuration as 'Default Product Configuration' and build. This is working fine. The Default configuration release is getting build.
But, how can we achieve this in MSBuild command line?
I need to build both configuration separately using MSBuild command line (without changing Default configuration through IDE).
Could anyone please share the proper way to build IS project in MSBuild command line?
Thanks,
Saravanan
how can we achieve this in MSBuild command line?
You can use Properties in the MSBuild command line:
msbuild test.sln /t:project /p:Configuration="Release" /p:Platform="x86" /p:BuildProjectReferences=false
You can also build multiple projects at once:
msbuild test.sln /t:project;project2 /p:Configuration="Release" /p:Platform="x86" /p:BuildProjectReferences=false
Note:
what is assigned to /t is the project name in the solution, it can be different from the project file name.
One important note: if your project has a '.' in the name, you'll need to replace it with a '_' when specifying it with /t
I have an MSBuild command line that can build an entire solution. It looks something like this:
msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /nodeReuse:false /maxcpucount:4 /t:Build
I know that for C++ Solutions, specific projects can be targeted using the following syntax:
msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /nodeReuse:false /maxcpucount:4 /t:Folder\SomeCppProject;Build
I'm trying to achieve the same thing for .NET projects within a solution. This does NOT work:
msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /nodeReuse:false /maxcpucount:4 /t:SomeDotNetProject;Build
Does anyone know how to target a specific project within a solution using MSBuild on the command line for .NET projects? I know I can create a custom MSBuild project to achieve what I'm after, but I need to share the solution and projects with Visual Studio.
Thanks!
-Sean
You'll need to specify any solution folders in the Visual Studio solution file, and replace any "." in the project name with "_":
msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /t:Folder\Project_Name
For example, if you have a project in the solution folder "Deploy" named "MyApplication.Deployment.csproj", you'll need
msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /t:Deploy\MyApplication_Deployment
Incidentially this is a solution folder, as displayed in Visual Studio, not a file system folder: those are ignored.
You can use the following commandline for building your project using msbuild from commandline
msbuild Solution.sln /p:Configuration=Release;Platform=x86 /t:ProjectName:Rebuild
Invoke MSBuild on the project file instead of the solution file (ref.msbuild /?)
msbuild SomeDotNetProject\SomeDotNetProject.csproj /p:Configuration:CustomDebug;Platform=OurPlatform /nodeReuse:false /maxcpucount:4 /t:Build
I have a report project that I want to script deploying to a development server. I need to just change the TargetServerUrl in the project properties. Is there a way to do this?
i.e.
&devenv.exe RSReports.sln /project Reports\Reports.rptproj /deploy
maybe => properties:TargetServerUrl=http://myserver/ReportServer
I know nothing about report projects but in almost every VS project you can define multiple "Configuration"s (the defaults are Debug and Release). So you can have one target in debug and another in Release mode, and use the command line
devenv /deploy Release RSReports.sln
Another option is to use the msbuild.exe utility to build your project (instead of devenv), and use it's proprerty replacemnet parameter
"c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" "Full path to soulution" /t:Build /p:Configuration=Release /p:TargetServerUrl=http://myserver/ReportServer
I am working on a large C++ solution in Visual Studio 2005. I want to log all of the output from the build of one project within that solution. The output window in VS seems to be malfunctioning. I suspect there is too much output for it to handle. I can't copy the output and I can't even save it to disk.
My idea is to build the project on the command line and just redirect the output to a file. I'm not sure what command I have to execute in order to build a project in the context of a solution. I tried to just vcbuild the project, but I think it's missing data inherited from the solution.
Any ideas?
Use DevEnv from the command line:
DevEnv /Build Debug /Project ProjectName %SOLUTION_FILE%
where %SOLUTION_FILE% is an environment variable holding the full
path to the solution file and ProjectName is the name of the project.
The output will go to standard output.
The entire solution can be rebuild with:
DevEnv /Rebuild Debug %SOLUTION_FILE%
Example; for an (installer) project named MSQuantSetup:
set SOLUTION_FILE=D:\dproj\MSQall\MSQuant\MSQuant.sln
DevEnv /Build Debug /Project MSQuantSetup %SOLUTION_FILE%
Or directly without the environment variable:
DevEnv /Build Debug /Project MSQuantSetup D:\dproj\MSQall\MSQuant\MSQuant.sln
Take a look at this page, I think this is what you are looking for. Don't forget the /Project parameter if you want to build only one project.
C# version with MSBuild (put the below code in a .bat file)
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v2.0.50727
call %msBuildDir%\msbuild ".\SomeFolder\MyCSharpProject.csproj" /p:Configuration=Release /l:FileLogger,Microsoft.Build.Engine;logfile=Manual_MSBuild_ReleaseVersion_One_Project_CSharp_LOG.log
set msBuildDir=
Or for C++:
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v2.0.50727
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319
call %msBuildDir%\msbuild ".\Project1\Project1\Project1.vcxproj" /p:Configuration=Release /l:FileLogger,Microsoft.Build.Engine;logfile=Manual_MSBuild_ReleaseVersion_One_Project_C_Plus_Plus_LOG.log
set msBuildDir=
You'll need to pick your framework (2.0 or 4.0 (or other??), where I have
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\vA.BCDEF
Just comment out or remove the framework version you do not want.
I had a solution with five (sub) projects. I built the "bottom most" project. And it only built this (single) assembly.
Keep in mind if the project you pick has dependencies, it'll build those as well. AKA, if you pick the "top most" assembly, it will build everything it needs.