Marnix
Marnix

Reputation: 6547

Use $(TargetName) or $(ProjectName) in OutputPath of csproj

I am trying to set the <OutputPath> of my C# project to the name of the project, but when the project builds, it only resolves $(SolutionDir) and not $(ProjectName) or preferably $(TargetName).

How can I use the target name in my <OutputPath>?

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>$(SolutionDir)bin\Release\plugins\$(ProjectName)</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <PlatformTarget>AnyCPU</PlatformTarget>
  </PropertyGroup>

Upvotes: 3

Views: 6883

Answers (1)

Marnix
Marnix

Reputation: 6547

I have found that you can use the defined properties that are used in the propertygroups in the complete csproj.

So I used $(AssemblyName):

<OutputPath>$(SolutionDir)bin\Release\plugins\$(AssemblyName)</OutputPath>

Upvotes: 11

Related Questions