I have a .csproj file I'm trying to configure to perform a build of a couple of projects, map drives to point to the output of the projects along with some support documents, build an installer, then unmap the drives. I keep getting erros when I call subst
to map the drive due to a trailing backslash in path. Here's the building and mapping targets
<Target Name="BuildApps">
<MSBuild Projects="..\MsApp\MsApp.csproj; ..\AvApp\AvApp.csproj"
Targets="Build">
<Output TaskParameter="TargetOutputs"
ItemName="PackageOutput"
/>
</MSBuild>
</Target>
<Target Name="MapDrives">
<Exec Condition="'%(PackageOutput.Filename)' == 'MsApp'" Command="subst O: "%(PackageOutput.Rootdir)%(PackageOutput.Directory)"" WorkingDirectory="C:" ContinueOnError="true" />
<Exec Condition="'%(PackageOutput.Filename)' == 'AvApp'" Command="subst P: "%(PackageOutput.Rootdir)%(PackageOutput.Directory)"" WorkingDirectory="C:" ContinueOnError="true" />
</Target>
In researching the problem, I came across this question on removing the backslash. When I modify the target to
<Target Name="MapDrives">
<PropertyGroup Condition="'%(PackageOutput.Filename)' == 'MsApp'">
<MsDirectory>%(PackageOutput.Directory)</MsDirectory>
</PropertyGroup>
<PropertyGroup Condition="'%(PackageOutput.Filename)' == 'AvApp'">
<AvDirectory>%(PackageOutput.Directory)</AvDirectory>
</PropertyGroup>
<Exec Condition="'%(PackageOutput.Filename)' == 'MsApp'" Command="subst O: "%(PackageOutput.Rootdir)$(MsDirectory.TrimEnd('\'))"" WorkingDirectory="C:" ContinueOnError="true" />
<Exec Condition="'%(PackageOutput.Filename)' == 'AvApp'" Command="subst P: "%(PackageOutput.Rootdir)$(AvDirectory.TrimEnd('\'))"" WorkingDirectory="C:" ContinueOnError="true" />
</Target>
I get the error
error MSB4190: The reference to the built-in metadata "Filename" at position 1 is not allowed in this condition "'%(PackageOutput.Filename)' == 'MsApp'"
Researching this error, I ran across this and the fact that properties are evaluated before items which may play a factor in the error. So, my question is there an easy way to remove the backslash by either converting this item list to a property or a way to perform a string operation on an item?