우리는 우리의 솔루션을 게시 동일한 필요가 있었다 여러 파일 공유 위치로 옮겨졌고 몇 달 전에 질문을 받았지만 답변은 커뮤니티에 도움이 될 것이라고 생각했습니다.
VS 게시 프로파일은 쉽게 확장 할 수있는 일반 MSBuild 파일이므로 여기에 나와있는 해결책이 있습니다.
좀 더 복잡한 빌드 프로세스에서 일부 코드 조각을 추출 했으므로 비트를 변경하지 않고도 작동한다는 것을 보장하지는 않습니다.
게시 프로필에서 사용자 지정 DeploymentPaths 항목을 아래와 같이 추가했습니다. 하나 이상의 추가 위치를 정의 할 수 있습니다.
<ItemGroup Label="Defines additional publish locations">
<DeploymentPaths Include="\\SERVER1\ShareFolder\ProjectA\" />
<DeploymentPaths Include="\\SERVER2\ShareFolder\ProjectA\" />
</ItemGroup>
은 그 때 나는
WebFileSystemPublish 후에 실행하는 사용자 정의 대상
CustomWebFileSystemPublish을 추가했다. 이 대상은 기존 파일 삭제를 수행하고 새 파일을 복사하는 다른 MSBuild 파일 인 publish.xml을 호출합니다.
마지막으로
<!-- Custom File System Publish to deploy to additional locations based on DeploymentPaths -->
<Target Name="CustomWebFileSystemPublish" AfterTargets="WebFileSystemPublish" Condition=" @(DeploymentPaths)!='' ">
<CreateItem Include="$(MSBuildProjectDirectory)\$(_PackageTempDir)">
<Output ItemName="AbsoluteSourcePathItem" TaskParameter="Include" />
</CreateItem>
<CreateProperty Value="%(AbsoluteSourcePathItem.Fullpath)">
<Output PropertyName="AbsoluteSourcePath" TaskParameter="Value" />
</CreateProperty>
<Message Text="### CustomWebFileSystemPublish" Importance="high" />
<Message Text="### DeploymentPaths: @(DeploymentPaths)" Importance="high" />
<MSBuild Projects="$(MSBuildProjectFile)" Properties="AbsoluteSourcePath=$(AbsoluteSourcePath)" Targets="DoPublish" />
</Target>
<Target Name="DoPublish">
<Message Text="### DoPublish $(AbsoluteOutputPath) | %(DeploymentPaths.Identity)" Importance="normal" />
<!-- Adjust path to the publish.xml file depending on where you put it in your solution -->
<MSBuild Projects="..\Deployment\publish.xml" Properties="OutputPath=$(AbsoluteSourcePath);DeployPath=%(DeploymentPaths.Identity)" />
</Target>
, 여기에 publish.xml MSBuild에서 내가 마음에 그런 작은 몇 가지를 행한 대한
<!-- Publish.xml -->
<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Start">
<PropertyGroup>
<!-- Ensure DeployPath has the expected trailing slash -->
<DeployPath Condition=" '$(DeployPath)' != '' and !HasTrailingSlash('$(DeployPath)') ">$(DeployPath)\</DeployPath>
</PropertyGroup>
<Message Text=" # Deploying from $(OutputPath) to $(DeployPath) " Importance="normal" />
</Target>
<Target Name="CleanDeployFolder" DependsOnTargets="Start"
Condition=" $(DeployPath)!=''">
<Message Text=" # Cleaning files in $(DeployPath)" Importance="normal" />
<!-- Defines the files to clean -->
<ItemGroup>
<DeployCleanFiles Include="$(DeployPath)\**\*.*" />
</ItemGroup>
<!--Delete files in Deploy folder (folders not deleted by Delete Task)-->
<Delete Files="@(DeployCleanFiles)" />
<Message Text=" # Cleaning files in $(DeployPath) Completed" Importance="normal" />
</Target>
<Target Name="CopyToDeployFolder" DependsOnTargets="CleanDeployFolder"
Condition=" $(DeployPath)!=''">
<Message Text=" # Copying files to $(DeployPath)" Importance="normal" />
<ItemGroup>
<OutputFiles Include="$(OutputPath)\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(OutputFiles)" DestinationFolder="$(DeployPath)%(OutputFiles.RecursiveDir)" />
<Message Text=" # Copying files to $(DeployPath) Completed" Importance="normal" />
</Target>
<Target Name="Default" DependsOnTargets="CopyToDeployFolder"
Condition=" $(OutputPath)!='' And $(DeployPath)!='' ">
<Message Text=" # Deploying from $(OutputPath) to $(DeployPath) Completed" Importance="normal" />
</Target>
</Project>
감사를 제출하지만, 정말 그냥 어떻게 든 내 모든 것을 유지하기 위해 찾고있다 가능한 경우 기능과 솔루션을 게시하십시오. 그러나 좋은 제안 덕분에. – Cragly