MSBuild targets and Visual Studio 2012 issues
Asked Answered
R

2

7

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?

Redound answered 20/9, 2012 at 20:7 Comment(0)
R
8

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>
Redound answered 25/9, 2012 at 9:4 Comment(0)
K
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.

Kohn answered 25/9, 2012 at 3:48 Comment(2)
FYI Vs2010 also used msbuild 4.0Pires
I know ;). You don't need VS at all. MSBuild part of .NET FW, so you can use it without studio at all. Except that vs2010 not truly using msbuild.exe, but VS2012 does. But this stuff is nitpicking, not related to question and answer.Kohn

© 2022 - 2024 — McMap. All rights reserved.