Domanda

Vorrei sapere come compilare i file ASPX dopo la bobina in una soluzione di SharePoint per vedere gli errori di runtime, ad es.Risorsa mancante (quando si traduce la pagina utilizzando risorse).

Quando aggiungo l'attività AspNetCompiler nel mio CSproj come questa (mostrando solo la fine del file del progetto):

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

Quindi quando si crea il progetto ottengo il seguente errore nel file ASPX:

.

Impossibile caricare file o assembly '$ sharepoint.project.assemblyfullname $' o una delle sue dipendenze.Il sistema non riesce a trovare il file specificato.

Ovviamente il compilatore ASP tenta di creare i file ASPX nella directory del progetto che non hanno i token sostituiti.Tuttavia, non sono stato in grado di finalizzare l'attività in modo da utilizzare sui campi con i token sostituiti.La mia conoscenza di MSbuild è limitata che potrebbe essere il problema.

È stato utile?

Soluzione

L'unico modo per eseguire la sostituzione del token è creare il pacchetto WSP perché la sostituzione si verifica lì.La soluzione è quindi quella di creare il WSP, disimballare in una cartella di destinazione, creare una nuova directory chiamata "BIN", spostare le DLL nella directory Bin e quindi eseguire il compilatore ASPNET nella cartella Target.L'intero processo può essere fatto nel file MSBuild (CSPROJ).Questa è la mia soluzione - alla fine del file csproj, dopo aver importato i bersagli di SharePoint:

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

Modifica: Il processo è un po 'più complicato.Secondo il tuo progetto, devi spostare alcuni file in cartelle specifiche.Fondamentalmente, segui ciò che ti viene detto dal compilatore.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top