Adding a CAS permission set to a Visual Studio 2010 SharePoint package manifest causes F5 Deployment to fail

Article ID: 2022463 - View products that this article applies to.
Expand all | Collapse all

Symptoms

 

Adding CAS permissions to a Visual Studio 2010 SharePoint package manifest will cause F5 and deployment to fail with the following error ‘Error occurred in deployment step ‘Add solution’: Property set method not found.’

Cause

 

ClassName property not handled correctly by the deployment step.

Resolution

 

Create a custom targets file to insert a custom target post-package that opens the package manifest, removes the class attribute from each PermissionSet element, and saves the modified manifest.

An example custom targets file is shown below.  It should be named “Custom.After.Microsoft.VisualStudio.SharePoint.targets” and placed in the “<Program Files (x86)>\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools” folder.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

 

  <UsingTask TaskName="FixPackageManifestTask" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">

 

    <ParameterGroup>

      <Manifest ParameterType="Microsoft.Build.Framework.ITaskItem" Required="true" />

    </ParameterGroup>

 

    <Task>

 

      <Reference Include="System.Xml" />

      <Reference Include="System.Xml.Linq" />

 

      <Using Namespace="System.IO" />

      <Using Namespace="System.Xml.Linq" />

 

      <Code Type="Fragment" Language="cs">

<![CDATA[

 

  string fullPath = Manifest.GetMetadata("FullPath");

 

  if (File.Exists(fullPath))

  {

    var doc = XDocument.Load(fullPath);

    var ns = XNamespace.Get("http://schemas.microsoft.com/sharepoint/");

 

    var permissionSetElements = doc.Descendants(ns + "PermissionSet");

 

    foreach (var permissionSetElement in permissionSetElements)

    {

      permissionSetElement.SetAttributeValue("class", null);

    }

 

    doc.Save(fullPath);

  }

 

]]>

      </Code>

 

    </Task>

 

  </UsingTask>

 

  <PropertyGroup>

 

    <CreatePackageDependsOn>

      $(CreatePackageDependsOn);

      FixPackageManifest

    </CreatePackageDependsOn>

 

  </PropertyGroup>

 

  <Target Name="FixPackageManifest">

    <FixPackageManifestTask Manifest="$(LayoutPath)%(EnumeratedFiles.Package)\manifest.xml" />

  </Target>

 

</Project>

Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Properties

Article ID: 2022463 - Last Review: April 12, 2010 - Revision: 1.0
APPLIES TO
  • Microsoft Visual Studio 2010 Professional
  • Microsoft Visual Studio 2010 Ultimate
Keywords: 
KB2022463

Give Feedback

 

Article Translations