Question

J'aimerais savoir comment compiler des fichiers ASPX après la construction d'une solution SharePoint pour voir les erreurs d'exécution, par ex.ressource manquante (lors de la traduction de la page en utilisant des ressources).

Lorsque j'ajoute la tâche ASPnetCompiler dans mon CSPROJ comme ceci (indiquant la fin du fichier de projet):

...
<PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
  </PropertyGroup>
  <Import Project="$(VSToolsPath)\SharePointTools\Microsoft.VisualStudio.SharePoint.targets" Condition="'$(VSToolsPath)' != ''" />
  <Target Name="AfterBuild">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" />
    <!-- ToolPath="C:\Windows\Microsoft.NET\Framework64\v2.0.50727" -->
  </Target>
  <PropertyGroup>
    <PostBuildEvent>
    </PostBuildEvent>
  </PropertyGroup>
</Project>

Puis, lorsque vous construisez le projet, j'obtiens l'erreur suivante dans le fichier ASPX:

ne pouvait pas charger le fichier ou l'assemblage "$ SharePoint.Project.assemblyfulName $ 'ou une de ses dépendances.Le système ne peut pas trouver le fichier spécifié.

Évidemment, le compilateur ASP tente de construire les fichiers ASPX dans le répertoire de projet qui ne sont pas remplacés par les jetons.Cependant, je n'ai pas pu finaliser la tâche pour que cela fonctionnerait sur des champs avec les jetons remplacés.Ma connaissance de Msbuild est limitée, ce qui pourrait être le problème.

Était-ce utile?

La solution

Le seul moyen de remplacer le jeton consiste à créer le paquet WSP car le remplacement se produit là.La solution consiste alors à créer le WSP, à décompresser dans un dossier cible, créez un nouveau répertoire appelé "bin", déplacez les DLL dans le répertoire des bacs, puis exécutez le compilateur ASPnet sur le dossier cible.L'ensemble du processus peut être effectué dans le fichier MsBuild (CSPROJ).C'est ma solution - à la fin du fichier CSPROJ, une fois que les objectifs SharePoint sont importés:

  <Import Project="$(VSToolsPath)\SharePointTools\Microsoft.VisualStudio.SharePoint.targets" Condition="'$(VSToolsPath)' != ''" />
  <PropertyGroup>
    <!-- schedule creating the package in the build, the task is defined in sharepoint targets -->
    <BuildDependsOn>$(BuildDependsOn);CreatePackage</BuildDependsOn>
    <PostBuildEvent>
    </PostBuildEvent>

    <!-- define file/folder properties -->
    <ExpandDest>$(TargetDir)_wsp</ExpandDest>
    <WspBinPath>$(ExpandDest)\bin</WspBinPath>
    <WspPath>$(TargetDir)MyProject.wsp</WspPath>    
  </PropertyGroup>

  <!-- override "after build" target, it must depend on the package creation, 
       which ensures that the target runs after we have the wsp package ready -->
  <Target Name="AfterBuild" DependsOnTargets="CreatePackage">
    <!-- create the folder where we unpack our wsp -->
    <MakeDir Directories="$(ExpandDest)" />    
    <!-- use expand to unpack the wsp -->
    <Message Text="$(ExpandWsp)" Importance="high" />
    <Exec Command="expand &quot;$(WspPath)&quot; -F:* &quot;$(ExpandDest)&quot;" />

    <!-- create the "bin" folder -->
    <MakeDir Directories="$(WspBinPath)" />
    <!-- move all dlls and xmls from the root to the bin folder -->
    <Exec Command="move /Y &quot;$(ExpandDest)\*.dll&quot; &quot;$(WspBinPath)&quot;" />
    <Exec Command="move /Y &quot;$(ExpandDest)\*.xml&quot; &quot;$(WspBinPath)&quot;" />

    <!-- run the aspnet compiler on the wsp folder,
         the tool path param ensures that .net 2 compiler will be used,
         we need that because we compile sharepoint 2010 which is .net 3.5
         and the latest aspnet compiler for .net 3.5 is in .net 2 -->
    <AspNetCompiler 
      VirtualPath="/"
      PhysicalPath="$(ExpandDest)"
      Clean="true"
      ContinueOnError="false"
      ToolPath="C:\Windows\Microsoft.NET\Framework\v2.0.50727" />
  </Target>
</Project>

EDIT: Le processus est un peu plus compliqué.Selon votre propre projet, vous devez déplacer certains fichiers sur des dossiers spécifiques.Fondamentalement, suivez ce que vous êtes raconté par le compilateur.

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top