我有一个我在日常构建期间运行的Release.proj文件。它应该构建我的云服务,然后将\ bin \ app.publish文件夹的内容复制到另一个新创建的文件夹。它正在构建解决方案,但内容不会被复制。我也尝试过使用DependsOnTaret属性。这似乎是时间问题。 Follweing是我的Release.proj文件的样子:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="PrepareRelease" ToolsVersion="4.0" >
<PropertyGroup>
<ReleaseFolderPath/>
<ReleaseFolderPath Condition=" '$(OutDir)'=='' ">$(Configuration)\</ReleaseFolderPath>
......
........
.......
<Configuration Condition="'$(Configuration)'=='' ">Release</Configuration>
</PropertyGroup>
<ItemGroup>
<Package Include="..\AzureCloudService\bin\Release\app.publish\*.*"/>
</ItemGroup>
<Target Name="PrepareRelease">
<MSBuild Targets="Publish" Projects="..\AzureService.sln" Properties="Configuration=Release;">
</MSBuild>
<MakeDir Directories="$(ReleaseFolderPath)\Package" />
<Copy SourceFiles="@(Package)" DestinationFolder="$(ReleaseFolderPath)\Package" />
</Target>
</Project>
答案 0 :(得分:0)
我想在“AzureCloudService \ bin \ Release \ app.publish \”中的文件将在MSBuild发布调用期间创建,对吧?如果是这样,只需在目标中移动ItemGroup定义:
<Target Name="PrepareRelease">
<MSBuild Targets="Publish" Projects="..\AzureService.sln" Properties="Configuration=Release;" />
<ItemGroup>
<Package Include="..\AzureCloudService\bin\Release\app.publish\*.*"/>
</ItemGroup>
<MakeDir Directories="$(ReleaseFolderPath)\Package" />
<Copy SourceFiles="@(Package)" DestinationFolder="$(ReleaseFolderPath)\Package" />
</Target>
当ItemGroup元素在目标之外时,它将在调用任何目标之前定义,这意味着如果在构建开始时没有文件存在,它将为空。