문제

SharePoint 솔루션에서 빌드 된 후 ASPX 파일을 컴파일하는 방법을 알고 싶습니다.누락 된 리소스 (리소스를 사용하여 페이지를 번역 할 때).

이와 같이 AspNetCompiler 태스크를 내 csproj에 추가 할 때 (프로젝트 파일의 끝 부분 만 표시) :

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

그런 다음 프로젝트를 작성할 때 ASPX 파일에서 다음 오류가 발생합니다.

파일 또는 어셈블리 '$ SharePoint.Project.AssemblyFullName $'또는 종속성 중 하나를로드 할 수 없습니다.시스템이 지정된 파일을 찾을 수 없습니다.

분명히 ASP 컴파일러는 토큰이 교체되지 않은 프로젝트 디렉토리에 ASPX 파일을 빌드하려고 시도합니다.그러나 토큰이 교체 된 필드에서 작동하도록 작업을 완료 할 수 없었습니다.MSBuild에 대한 나의 지식은 제한되어 있으므로 문제가 될 수 있습니다.

도움이 되었습니까?

해결책

토큰 교체를 수행하는 유일한 방법은 교체가 발생하기 때문에 WSP 패키지를 만드는 것입니다.그런 다음 솔루션은 WSP를 만들고 대상 폴더에 압축을 풀고 "bin"이라는 새 디렉토리를 만들고 DLL을 BIN 디렉토리로 이동 한 다음 대상 폴더에서 ASPNET 컴파일러를 실행합니다.전체 프로세스는 msbuild (csproj) 파일에서 수행 할 수 있습니다.SharePoint 대상이 가져온 후 Csproj 파일의 끝에서 내 솔루션입니다.

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

편집 : 프로세스는 조금 더 복잡합니다.자신의 프로젝트에 따르면 일부 파일을 특정 폴더로 이동해야합니다.기본적으로 컴파일러가 당신이 들리는 것을 따르십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top