How to set the output path of several visual C# projects

A csproj file is already an msbuild file, this means that csproj files can also use an import element as described here. The import element is
exactly what you require. You could create a Common.proj that contains something like:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5"xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
    <OutputPath>$(SolutionDir)output</OutputPath>
    <WarningLevel>4</WarningLevel>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</Project>

You can import this Common.proj in each of your csprojs, for instance like so:

<Import Project="..\Common.proj" />

The import statement should precede any tasks that depend on the properties defined in Common.proj

I hope this helps. I can’t confirm your problems with the $(SolutionDir) variable I’ve used it many times. I do know however that this variable does not get set when you run an msbuild command via the commandline on a specific project that is contained in a solution. It will be set when you build your solution in Visual Studio.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)