At the beginning the property sheet has been integrate from Visual Studio for C++ project.
You can centralize common information in this file and he can be used from all projects.
I would like to centralize the output directory of my all c# project.
Step 1 :
Create a *.targets file.
Example : ( MainPropertySheet.targets)
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <MainOutDir>$(SolutionDir)..\libs\VS2013\$(Configuration)\$(Platform)\</MainOutDir> <MainConfiguration Condition="'$(Configuration)'=='Debug'">Debug</MainConfiguration> <MainConfiguration Condition="'$(Configuration)'=='Release'">Release</MainConfiguration> <MainConfiguration Condition="'$(Configuration)'=='Release_with_PDB'">Release</MainConfiguration> </PropertyGroup> </Project>
As you can see, I created 2 variables, « MainOutDir » and « MainConfiguration ».
For using this variable, you should write $(MainOutDir).
Step 2 :
Use our *.targets file in a other projects.
Open your *.csproj file with notepad.
Add this at the top of your file :
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(ProjectDir)..\..\..\Build\VS2013\MainPropertySheet.targets" /> <PropertyGroup Condition="'$(MainConfiguration)|$(Platform)' == 'Release|x64'"> <OutputPath>$(MainOutDir)</OutputPath> ... </PropertyGroup> </Project>
Save your file and reopen with visual. Enjoy !