I've got a nice solution with a desktop application project, a few library projects, and a couple of development tools projects (also desktop applications). At the moment, my build server outputs all of the code into one OutputPath
. So we end up with
drop-x.y.z\ Company.MainApplication.exe <-- main application Company.MainApplicationCore.dll <-- libraries Helper.exe <-- developer tools Grapher.exe Parser.exe ... <-- the rest of the output
But, we're growing up and people outside of our team want access to our tools. So I want to organize the output. I decided that what we would want is a different OutputPath
per executable project
drop-x.y.z\ Company.MainApplication\ Company.MainApplication.exe <-- main application Company.MainApplicationCore.dll <-- libraries ... <-- application specific output Helper\ Helper.exe <-- developer tools ... <-- tool specific output Grapher\ Grapher.exe ... Parser\ Parser.exe ...
I found this simple command. I like it because it retains all the Solution working-dir context that makes msbuild a pain.
msbuild /target:<ProjectName>
For example, from my solution root as a working directory, I would call
PS> msbuild /target:Helper /property:OutputPath="$pwd\out\Helper"
I'm testing this from PowerShell, so that $pwd
resolves to the full path to my working directory, or the Solution root in this case. I get the output I desire.
However, when I run this command
PS> msbuild /target:Company.MainApplication /property:OutputPath="$pwd\out\Company.MainApplication"
I get the following error output (there's no more information, I ran with /verbosity:diagnostic
)
The target "Company.MainApplication" does not exist in the project.
The command fails on any project with a dot or dots in the name. I tried with many combinations of working directories and properties. I tried several ways of escaping the property values. I also tried running the command from a <Task>
in a targets file.
I need to know either
A) How to fix this command to work property
B) How to achieve the same output with minimal friction
To build a specific target of a specific project in a solution. At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.
In the Visual Studio installer, navigate to Individual Components, and locate the checkbox for MSBuild. It is automatically selected when you choose any of the other workloads to install. To install MSBuild on a system that doesn't have Visual Studio, go to Build Tools for Visual Studio 2022 on the downloads page.
MSBuild is now installed in a folder under each version of Visual Studio. For example, C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild . You can also use the following PowerShell module to locate MSBuild: vssetup. powershell.
Try using an underscore as an escape character for the dot in the target parameter, e.g.
msbuild /target:Company_MainApplication /property:OutputPath="$pwd\out\Company.MainApplication"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With