views:

328

answers:

2

I'm currently in the process of setting up a build server for a web project. I'm using Web Deployment Project to create a deployable package and I want to do some simple file administration (copy webDeploy.config -> web.config and delete .csproj files).

My target looks as follows:

<Target Name="AfterBuild">      
    <Delete Files="$(OutputPath)\*.csproj" />
</Target>

However, inspecting the output of the WDP gives me this

Target "AfterBuild" in file "C:\project\Deployment\Project.Deployment.wdproj": 
    Task "Delete"
        File ".\Debug\*.*" doesn't exist. Skipping.   
    Done executing task "Delete". 
Done building target "AfterBuild" in project "Project.Deployment.wdproj".

The Deployment path does indeed contain a Debug path. What am I doing wrong?

A: 

I tried it myself and was stunned but the explanation is simple: You cannot use wildcards (MSBuild Team Blog).

Sample:

<ItemGroup>
    <ProjectConfigFiles Include="$(OutputPath)\*.csproj" />
</ItemGroup>

<Target Name="AfterBuild">      
    <Delete Files="@(ProjectConfigFiles)" />
</Target>
Filburt
There's a way around that actually, check Sayeds answer.
Bartek Tatkowski
+2  A: 

If you want to use wildcards you will have do so in an item list. The item list will take care of expanding the wild cards for you. So in your case:

<Target Name="AfterBuild">      
    <ItemGroup>
        <FilesToDelete = Include="$(OutputPath)\*.csproj" />
    </ItemGroup>
    <Delete Files="@(FilesToDelete)" />
</Target>
Sayed Ibrahim Hashimi