Question

I am making some changes in my csproj file so when I build debug it will copy a set of debug files and when I build release it will copy a set of release files.

The Start of the csproj:

<PropertyGroup>
...
<FlexNetInput></FlexNetInput>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
<FlexNetInput>"..\..\..\..\utilities\FlexNet\Debug\Native\"</FlexNetInput>
</PropertyGroup>
 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    ...
    <FlexNetInput>"..\..\..\..\utilities\FlexNet\Release\Native\"</FlexNetInput>
  </PropertyGroup>

At the end of the csproj this is what I have:

 <Target Name="AfterBuild">
    <!-- Copy Native DGI DLL's -->
    <CreateItem Include="..\..\..\..\utilities\dgi\DgiNative\**\*.*">
      <Output TaskParameter="Include" ItemName="NativeDgiFiles" />
    </CreateItem>
    <Copy SourceFiles="@(NativeDgiFiles)" DestinationFiles="@(NativeDgiFiles->'$(OutputPath)\Native\%(RecursiveDir)%(Filename)%(Extension)')" />
    <!-- Copy Native FlexNet DLL's -->
    <CreateItem Include="'$(FlexNetInput)'**\*.*">
    <Output TaskParameter="Include" ItemName="NativeReleaseFlexNetFiles" />
  </CreateItem>
  <Copy SourceFiles="@(NativeReleaseFlexNetFiles)" DestinationFiles="@(NativeReleaseFlexNetFiles->'$(OutputPath)\Native\%(RecursiveDir)%(Filename)%(Extension)')" />

The copy of the dgi file works fine, but because the location of the FlexNet file is different depending on if it is release or debug I cant get it to work.

The error I am getting is: Cannot evaluate the item metadata "%(Filename)". The item metadata "%(Filename)" cannot be applied to the path "'"........\utilities\FlexNet\Debug\Native\"***.*'". Illegal characters in path.

I don't think I am using the properties right, any ideas?

Solved, This is how I got it working:

<CreateItem Include="..\..\..\..\utilities\FlexNet\$(Configuration)\Native\**\*.*">
      <Output TaskParameter="Include" ItemName="NativeFlexNetFiles" />
    </CreateItem>
    <Copy SourceFiles="@(NativeFlexNetFiles)" DestinationFiles="@(NativeFlexNetFiles->'$(OutputPath)\Native\%(RecursiveDir)%(Filename)%(Extension)')" />
Was it helpful?

Solution

These days you should probably never need CreateItem anymore. ItemGroups can be placed inside targets, and will be evaluated when the target runs. Also since your output directory has the same name as your Configuration you can use it as a property. Together this gives

<ItemGroup>
  <NativeReleaseFlexNetFiles Include=
    "..\..\..\..\utilities\FlexNet\$(Configuration)\Native\**\*.*"/>
</ItemGroup>

in your AfterBuild target.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top