Déployer des fonctions définies par l’utilisateur à l’aide des solutions SharePoint Foundation

This example shows how to deploy a user-defined function (UDF) DLL by using the Microsoft SharePoint Foundation solution framework.

The SharePoint Foundation solution framework lets you bundle all the components to extend SharePoint Foundation in a new file called a solution file (a CAB-based format with a .wsp extension). A solution is a deployable, reusable package that can contain a set of features, site definitions, and assemblies that you can apply to a site, and individually enable or disable. En outre, vous pouvez utiliser le fichier de solution pour déployer le contenu d’un package de composants Web Part, y compris les assemblys, les ressources de classe, les fichiers .dwp et d’autres composants de package. For more information about the SharePoint Foundation solution framework, see the SharePoint Foundation node in the Mise en route du développement pour SharePoint Foundation (https://msdn.microsoft.com/library/ee539432(office.14).aspx).

The procedure for creating and deploying a UDF assembly by using SharePoint Foundation solution framework is as follows:

  1. Create the solution manifest file, Manifest.xml.

    The solution manifest (always called Manifest.xml) is stored at the root of a solution file. Ce fichier définit la liste des fonctionnalités, des définitions de site, des fichiers de ressources, des fichiers de partie Web et des assemblys à traiter. It does not define the file structure; if files are included in a solution but not listed in the manifest XML file, they are not processed in any way.

    Notes

    [!REMARQUE] For more information about the structure of the manifest XML file, see the SharePoint Foundation documentation.

  2. Package the UDF assembly and Manifest.xml into a CAB file.

  3. Make sure that the SharePoint Foundation Administration service is running on the server.

  4. Add the solution to the server by using stsadm.exe.

  5. Deploy the solution by using stsadm.exe.

Each Excel Services trusted location has an AllowUdfs flag.

Notes

[!REMARQUE] The AllowUdfs flag is denoted by the User-defined functions allowed option on the Excel Services Trusted File Locations page. To learn how to navigate to the Trusted File Locations page, see Step 3: Deploying and Enabling UDFs.

In order to allow UDFs to be called from a specific trusted location, you must:

  • Set the AllowUdfs value to true. The default value is false.
  • Add the UDF assembly to the trusted UDF list to allow the UDF to be called from a workbook.

For more information on how to enable UDFs and add UDFs to the trusted UDF list, see How to: Enable UDFs.

Notes

[!REMARQUE] To avoid name collision, give your UDF assemblies and their dependencies strong names, and name them as uniquely as possible. For more information, see Excel Services Best Practices and Excel Services Known Issues and Tips.

Procedure

Pour créer le fichier Manifest.xml

  1. Cliquez avec le bouton droit sur votre projet dans l'Explorateur de solutions, pointez sur Ajouter, puis cliquez sur Nouvel élément.
  2. Select XML File, and name the file Manifest.xml.
  3. Click Add.
  4. Add the following content to the file:
<?xml version="1.0" encoding="utf-8" ?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/" SolutionId="{57568687-2CC0-45bf-B66A-2D50D57108CA}" DeploymentServerType="ApplicationServer">
  <Assemblies>
    <Assembly DeploymentTarget="GlobalAssemblyCache" Location="EcsUdfsCommonSet.dll"/>
  </Assemblies>
</Solution>

Notes

[!REMARQUE] You should generate a unique GUID for each solution. Pour plus d’informations sur l’élément Solution, voir SharePoint Foundation Solutions et les packages de partie Web Part ( https://msdn.microsoft.com/library/ms413687.aspx) .

Pour créer un package de solution

  • Pour plus d’informations sur la création du fichier de solution, voir la rubrique « Création d’une solution » sous le nœud « Solutions et packages de partie Web » dans le SDK SharePoint Foundation.

Pour vérifier si SharePoint Foundation Administration est en cours d’exécution

  1. Cliquez sur Démarrer, pointez sur Outils d'administration, puis double-cliquez sur Services.

    The Services dialog box appears.

  2. Make sure that the status of SharePoint Foundation Administration service shows Started. If it does not, right-click SharePoint Foundation Administration, and then select Start.

Pour ajouter la solution

  1. Click Start, click Run, and then typecmd.

    The command prompt console appears.

  2. Exécutez le script suivant pour ajouter la solution au serveur SharePoint :

    stsadm.exe -o addsolution -filename <pathtoCAB>
    

Notes

[!REMARQUE] You can find the Stsadm.exe at: > C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN.

Notes

[!REMARQUE] For more information about Stsadm.exe command options, see the Stsadm to Windows PowerShell Mapping (SharePoint Foundation 2010) (https://technet.microsoft.com/library/ff621081.aspx).

Pour déployer la solution

  1. Click Start, click Run, and then typecmd.

    The command prompt console appears.

  2. Exécutez le script suivant pour déployer la solution sur le serveur SharePoint :

    stsadm.exe -o deploysolution -name <filename of the CAB> -immediate -allowGacDeployment
    

    Vous devez maintenant voir votre fichier DLL d'UDF dans le Global Assembly Cache.

Voir aussi

Tâches

Concepts