MSBuild targets and Visual Studio 2012 issues

二次信任 提交于 2019-11-28 00:36:55

问题


I'm having a hard time getting my third party non-reference assemblies deployed via Webdeploy withing the Visual Studio 2012 UI. I have a folder called 'libraries', which contains some assemblies. Via the following in my *.csproj file I can set the Build Action to 'ThirdPartyAssemblies':

<ItemGroup>
  <AvailableItemName Include="ThirdPartyAssemblies">
    <Visible>false</Visible>
  </AvailableItemName>
</ItemGroup>
<Target Name="AfterBuild">
  <Message Text="Build | Third party assemblies" Importance="high" />
  <Copy DestinationFolder="$(OutputPath)" SourceFiles="@(ThirdPartyAssemblies)" SkipUnchangedFiles="true" />
</Target>

This works great; when I build, the assemblies get copied to the root of the bin folder :-) Now I've got one problem: I can not get these files published to the server via Webdeploy. I've tried many things, it just seems like I can not find a suitable MSBuild target for this task... With Visual Studio 2010 I could use this:

<Target Name="MyTargetName">
  <Message Text="Deploy | Third party assemblies" Importance="high" />
  <Copy DestinationFolder="$(OutputPath)" SourceFiles="@(ThirdPartyAssemblies)" SkipUnchangedFiles="true" />
</Target>
<PropertyGroup>
  <OnAfterCopyAllFilesToSingleFolderForPackage>
    MyTargetName
  </OnAfterCopyAllFilesToSingleFolderForPackage>
</PropertyGroup>

The problem is; the OnAfterCopyAllFilesToSingleFolderForPackage target isn't called anymore :-/

After digging into the C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets' file, I've also tried 'OnAfterCopyAllFilesToSingleFolderForMsdeploy, but I just can't get it to work.

Can anyone tell me what target I can use to copy those assemblies to the Package folder / the server with Webdeploy?

Why doesn't Visual Studio 2012 copy the complete bin folder to the Package folder?


回答1:


Thanks to Alexey I found the solution to my problem, this is what I'm using now in my .csproj file to support copying third party assemblies for Filesystem- and Webdeploy:

<ItemGroup>
    <AvailableItemName Include="ThirdPartyAssemblies">
        <Visible>false</Visible>
    </AvailableItemName>
</ItemGroup>
<Target Name="AfterBuild">
    <Message Text="Build | Copying third party assemblies to output folder ($(OutputPath))" Importance="high" />
    <Copy DestinationFolder="$(OutputPath)" SourceFiles="@(ThirdPartyAssemblies)" SkipUnchangedFiles="true" />
</Target>
<Target Name="CopyBinFiles" AfterTargets="CopyAllFilesToSingleFolderForPackage" BeforeTargets="MSDeployPublish">
    <Message Text="Deploy | Copying third party assemblies to output folder ($(_PackageTempDir)\bin\)" Importance="high" />
    <Copy DestinationFolder="$(_PackageTempDir)\bin\" SourceFiles="@(ThirdPartyAssemblies)" SkipUnchangedFiles="true" />
</Target>



回答2:


You are using vs2012 and this mean you have shiny new msbuild 4.0 =). It's much simplier to hook your target call with new AfterTargets attribute. You can check my answer on this question for usage example.



来源:https://stackoverflow.com/questions/12520115/msbuild-targets-and-visual-studio-2012-issues

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!