Share via


How to: Customize a SharePoint Solution Package by Using MSBuild Targets

You can customize how Visual Studio creates SharePoint package files (.wsp) by using command-line MSBuild targets.

Customizing and Running MSBuild Targets

You can customize MSBuild targets to create a SharePoint package. For example, you can customize the MSBuild properties that specify the packaging intermediate directory and the MSBuild item groups that specify the enumerated files.

To customize the BeforeLayout target

  1. On the File menu, point to Open, and then click File.

  2. Navigate to the project folder.

  3. Click ProjectName.vbproj or ProjectName.csproj file, and then click Open.

  4. Replace <Target Name="BeforeLayout" /> with your custom code. For example, to display a message in this target, add the following code.

      <Target Name="BeforeLayout">
        <Message Text="In the BeforeLayout Target"></Message>
      </Target>
    

To customize the AfterLayout target

  1. On the File menu, point to Open, and then click File.

  2. Navigate to the project folder.

  3. Click ProjectName.vbproj or ProjectName.csproj file, and then click Open.

  4. Replace <Target Name="AfterLayout" /> with your custom code. For example, to display a message in this target, add the following code.

      <Target Name="AfterLayout">
        <Message Text="In the AfterLayout Target"></Message>
      </Target>
    

See Also

Other Resources

Packaging and Deploying SharePoint Solutions