Pregunta

Me gustaría saber cómo recopilar archivos ASPX después de construir en una solución de SharePoint para ver los errores de tiempo de ejecución, por ejemplo.Recurso faltante (al traducir la página usando recursos).

Cuando agrego la tarea ASPNETCompiler a mi CSPROJ como esta (solo que muestra el final del archivo del proyecto):

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

Luego, al crear el proyecto, obtengo el siguiente error en el archivo ASPX:

No se pudo cargar el archivo o el ensamblaje '$ SharePoint.Project.assemblyfullname $' o una de sus dependencias.El sistema no puede encontrar el archivo especificado.

Obviamente, el compilador ASP intenta construir los archivos ASPX en el directorio del proyecto que no tienen los tokens reemplazados.Sin embargo, no pude finalizar la tarea, por lo que operaría en campos con los tokens reemplazados.Mi conocimiento de Msbuild es limitado que podría ser el problema.

¿Fue útil?

Solución

La única forma de hacer el reemplazo del token es crear el paquete WSP porque se produce el reemplazo allí.La solución es para crear el WSP, desempaquetarlo a una carpeta de destino, cree un nuevo directorio allí llamado "bin", mueva las DLL al directorio Bin y luego ejecute ASPNET Compiler en la carpeta de destino.Todo el proceso se puede hacer en el archivo MSBUILD (CSPROJ).Esta es mi solución, al final del archivo CSPROJ, después de que se importen los objetivos de 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>

Editar: El proceso es un poco más complicado.Según su propio proyecto, debe mover algunos archivos a carpetas específicas.Básicamente, sigue lo que le dicen el compilador.

Licenciado bajo: CC-BY-SA con atribución
scroll top