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 solution pour déployer le contenu d’un package de composants WebPart, y compris les assemblys, les ressources de classe, les fichiers .dwp et d’autres composants de package. Pour plus d’informations sur l’infrastructure de solution SharePoint Foundation, consultez le nœud SharePoint Foundation dans la Prise en main avec développement pour SharePoint Foundation 2010 (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, définitions de site, fichiers de ressources, fichiers de composants WebPart et assemblys à traiter. Il ne définit pas la structure des fichiers ; si des fichiers sont inclus dans une solution mais qu'ils ne figurent pas dans le fichier XML manifeste, ils ne sont pas traités.

    Remarque

    [!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.

Remarque

[!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.

Pour plus d'informations sur l'activation des UDF et sur l'ajout d'UDF à la liste des UDF approuvées, voir How to: Enable UDFs.

Remarque

Pour éviter les conflits de noms, donnez des noms forts à vos assemblys UDF et à leurs dépendances et nommez-les de la façon la plus univoque possible. Pour plus d'informations, voir Excel Services Best Practices et 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. Ajoutez le contenu suivant au fichier :
<?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>

Remarque

Vous devez générer un GUID unique pour chaque solution. Pour plus d’informations sur l’élément Solution , consultez solutions sharePoint Foundation et packages de composants WebPart (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, consultez la rubrique « Création d’une solution » sous le nœud « Solutions et packages de composants WebPart » dans le Kit de développement logiciel (SDK) SharePoint Foundation.

Pour vérifier si l’administration de SharePoint Foundation 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>
    

Remarque

Vous trouverez le Stsadm.exe à l’adresse suivante : > C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN.

Remarque

Pour plus d’informations sur les options de commande Stsadm.exe, voir 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