Bartek Tatkowski
Bartek Tatkowski

Reputation: 975

Web Deployment Project AfterBuild path problems

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?

Upvotes: 3

Views: 1663

Answers (2)

Sayed Ibrahim Hashimi
Sayed Ibrahim Hashimi

Reputation: 44312

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>

Upvotes: 7

Filburt
Filburt

Reputation: 18061

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>

Upvotes: 0

Related Questions