visual-studiosharepointmsbuildwsp

Is there an MSBuild macro for the SharePoint project type package name?


I have a Visual Studio 2010/2012 solution with several SharePoint 2010 projects. On build or package event I want VS to auto-copy the output WSP and PDB files to a common folder at the root of my solution so I don't have to manually grab them from each project's bin\$(Configuration) folder.

I added the following elements to each project file:

<Target Name="CopyPackage">
  <Exec WorkingDirectory="$(PackagePath)" Command="copy &quot;$(TargetDir)$(TargetName).wsp&quot; &quot;$(SolutionDir)Builds\$(TargetName).wsp&quot;" ContinueOnError="False" />
  <Exec WorkingDirectory="$(PackagePath)" Command="copy &quot;$(TargetDir)$(TargetName).pdb&quot; &quot;$(SolutionDir)Builds\$(TargetName).pdb&quot;" ContinueOnError="False" />
</Target>
<PropertyGroup>
  <BuildDependsOn>$(BuildDependsOn);CreatePackage;CopyPackage</BuildDependsOn>
</PropertyGroup>

So far so good, that works fine.

Each project Package name controls the name of the output WSP file and can be different than the name of the output assembly DLL file.

Visual Studio SharePoint Project Package Name http://imageshack.us/a/img842/322/vsspprojectpackagename.png

In this example the WSP will be named Acme.Edms.SP.ContentTypes.WSP.

It happens that I want my WSP to use a somewhat different name from the project and assembly. But if I change the Package name it breaks the CopyPackage target which uses $(TargetName) that maps to the assembly name.

Is there an MSBuild macro for the (SharePoint) package name so I can fix the above MSBuild elements in my project files?

More generally, does MSBuild have a set of macros specific to the SharePoint project and item types?

Something equivalent to Macros for Build Commands and Properties.

Thanks


Solution

  • Here is the list of SharePoint specific MSBuild properties and there is nothing about package name. So you have to use workaround for that e.g.

    First you get lists of package files and pdb files like that:

    <ItemGroup>
        <PackageFiles Include="$(BasePackagePath)\*.$(PackageExtension)" />
        <PdbFiles Include="$(BasePackagePath)\*.pdb)" />
    </ItemGroup>
    

    And then you can use it in regular copy command.

    I didn't test it but it should work.