我正在为网站使用visual studio 2012软件包功能,我有一个自定义目标,在压缩文件夹之前将一些子文件夹收集到软件包目标中。 这曾经在vs10中运行良好,但是对于新的打包器vs12,它不再关心任何这些配置并且它们没有正确迁移 任何方式做类似的事情,所以我的包最终将有这些文件?
这是它在vs10中的样子:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<!-- Begin copy Contracts &Provider directories -->
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
<DesktopBuildPackageLocation>..\Package\Release\projectname.zip</DesktopBuildPackageLocation>
<DeployIisAppPath>projectname</DeployIisAppPath>
<!-- End copy Contracts &Provider directories -->
</PropertyGroup>
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="$(OutputPath)\Contracts\**\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>bin\Contracts\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
<ItemGroup>
<_CustomFiles Include="$(OutputPath)\Providers\**\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>bin\Providers\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
在新项目中完全忽略了这一点。做类似事情的好方法是什么?
答案 0 :(得分:13)
找到解决方案,只需将CopyAllFilesToSingleFolderForPackageDependsOn
重命名为CopyAllFilesToSingleFolderForMsdeployDependsOn
,文件应包含在部署包中。
答案 1 :(得分:2)
另一种方法也有效,需要较少的维护..
<Target Name="CustomFolderDeploy" AfterTargets="CopyAllFilesToSingleFolderForPackage" BeforeTargets="MSDeployPublish">
<PropertyGroup>
<CustomFolder>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\..\..\..\Lib\CustomFolder'))</CustomFolder>
</PropertyGroup>
<CreateItem Include="$(CustomFolder)\*.*">
<Output TaskParameter="Include" ItemName="CustomFiles" />
</CreateItem>
<Copy SourceFiles="@(CustomFiles)" DestinationFolder="$(MSBuildProjectDirectory)\obj\$(Configuration)\Package\PackageTmp\bin" SkipUnchangedFiles="True" ContinueOnError="False" />
</Target>