Edit

Share via


CombinePath task

Combines the specified paths into a single path.

Task parameters

The following table describes the parameters of the CombinePath task.

Parameter Description
BasePath Required String parameter.

The base path to combine with the other paths. Can be a relative path, absolute path, or blank.
Paths Required ITaskItem[] parameter.

A list of individual paths to combine with the BasePath to form the combined path. Paths can be relative or absolute.
CombinedPaths Optional ITaskItem[] output parameter.

The combined path that is created by this task.

Remarks

In addition to the parameters listed above, this task inherits parameters from the TaskExtension class, which itself inherits from the Task class. For a list of these additional parameters and their descriptions, see TaskExtension base class.

The following example shows how to create an output folder structure using CombinePath to construct the property $(OutputDirectory) by combining a root path $(PublishRoot) concatenated with $(ReleaseDirectory) and a subfolder list @(LangDirectories).

 <PropertyGroup>
   <OutputType>Exe</OutputType>
   <TargetFramework>netcoreapp3.1</TargetFramework>
   <PublishRoot>C:\Site1\</PublishRoot>
   <ReleaseDirectory>Release\</ReleaseDirectory>
 </PropertyGroup>

 <ItemGroup>
   <LangDirectories Include="en-us\;fr-fr\"/>
 </ItemGroup>

 <Target Name="CreateOutputDirectories" AfterTargets="Build">
   <CombinePath BasePath="$(PublishRoot)$(ReleaseDirectory)" Paths="@(LangDirectories)" >
     <Output TaskParameter="CombinedPaths" ItemName="OutputDirectories"/>
   </CombinePath>
   <MakeDir Directories="@(OutputDirectories)" />
 </Target>

The only property that CombinePath allows to be a list is Paths, in which case the output is also a list. So, if $(PublishRoot) is C:\Site1\, and $(ReleaseDirectory) is Release\, and @(LangDirectories) is en-us;fr-fr\, then this examples creates the folders:

  • C:\Site1\Release\en-us\
  • C:\Site1\Release\fr-fr\

See also