ASP.NET 웹 응용 프로그램에 여러 개의 XSLT가 사용되었습니다. 프로젝트를 빌드 할 때마다이 파일을 dll로 컴파일해야합니다. 현재 vs2010 tools 명령 프롬프트에서 xsltc.exe를 호출하여 xslts를 수동으로 컴파일하고 있습니다.XSLTC.EXE MSBuild Task
xsltc.exe에 대한 msbuild 작업을 추가하여 프로젝트를 빌드 할 때 어셈블리를 생성 할 수 있습니까?
.NET 4.0을 사용하고 있습니다.
ASP.NET 웹 응용 프로그램에 여러 개의 XSLT가 사용되었습니다. 프로젝트를 빌드 할 때마다이 파일을 dll로 컴파일해야합니다. 현재 vs2010 tools 명령 프롬프트에서 xsltc.exe를 호출하여 xslts를 수동으로 컴파일하고 있습니다.XSLTC.EXE MSBuild Task
xsltc.exe에 대한 msbuild 작업을 추가하여 프로젝트를 빌드 할 때 어셈블리를 생성 할 수 있습니까?
.NET 4.0을 사용하고 있습니다.
<PropertyGroup>
<WinSDK>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin</WinSDK>
</PropertyGroup>
<Target Name="Build">
<Exec Command="%22$(WinSDK)\xsltc.exe%22 /out:$(OutputPath)\_PublishedWebsites\xyzapp\bin\Xslts.dll /class:ABC %22$(MSBuildProjectDirectory)\xyzapp\a.xslt%22 /class:DEF %22$(MSBuildProjectDirectory)\xyzapp\b.xslt%22 /class:GHI %22$(MSBuildProjectDirectory)\xyzapp\c.xslt%22"/>
</Target>
실제로 작동하지만 실제로는 MSBuild 친숙한 방식으로 도구를 포장하지는 않습니다. 나는 이걸 생각해 냈다.
<!-- The Transform File Names... -->
<ItemGroup>
<XsltcTransform Include="Transform1.xslt">
<!-- And the generated .Net Class name. -->
<Class>Transform1Class</Class>
</XsltcTransform>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- Sadly using $(OutDir) MUST come after the Import of CSharp.targets -->
<PropertyGroup>
<XSLTCOutputDll>$(OutDir)xslts.dll</XSLTCOutputDll>
</PropertyGroup>
<Target Name="FindXSLTC">
<PropertyGroup>
<XSLTC>"$(TargetFrameworkSDKToolsDirectory)xsltc.exe"</XSLTC>
</PropertyGroup>
</Target>
<Target Name="XSLTC" Inputs="@(XsltcTransform)" Outputs="$(XSLTCOutputDll)" DependsOnTargets="FindXSLTC">
<Exec Command="$(XSLTC) /out:"$(XSLTCOutputDll)" @(XsltcTransform -> ' /class:%(Class) %(FullPath) ')" />
</Target>
<Target Name="BeforeResolveReferences" DependsOnTargets="XSLTC">
</Target>
이러한 대상을 사용하면 여러 개의 변환을 하나의 DLL로 컴파일 할 수 있습니다. "BeforeResolveRefereneces"전에 XSLTC를 실행해야 생성 된 DLL에 대한 어셈블리 참조를 가질 수 있습니다.