Benutzer:MovGP0/NET/Transformations
Zur Navigation springen
Zur Suche springen
MovGP0 | Über mich | Hilfen | Artikel | Weblinks | Literatur | Zitate | Notizen | Programmierung | MSCert | Physik |
Text Transformations (T4)[Bearbeiten | Quelltext bearbeiten]Aktivierung von T4 in MSBuild[Bearbeiten | Quelltext bearbeiten] <?xml version="1.0" encoding="utf-8"?>
<!-- adding 'TransformAll' target -->
<Project ToolsVersion="4.0" DefaultTargets="TransformAll;Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- importing Visual Studio Parameters -->
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<!-- setting standard values in case that properties are not imported successfully -->
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<!--
...
-->
<!-- import targets -->
<Import Project="$(VSToolsPath)\TextTemplating\Microsoft.TextTemplating.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\TextTemplating\Microsoft.TextTemplating.targets" Condition="false" />
<!-- setting new property -->
<PropertyGroup>
<outputDir>$(OutputPath)</outputDir>
<TransformOnBuild>true</TransformOnBuild>
<TransformFile>/**.tt</TransformFile>
</PropertyGroup>
<!-- tell MSBuild to use that property -->
<ItemGroup>
<T4ParameterValues Include="outputDir">
<Value>$(outputDir)</Value>
<InProject>False</InProject> <!-- hide object in Visual Studio -->
</T4ParameterValues>
</ItemGroup>
</Project>
Verwendung: <#@ assembly name="$(outputDir)\MyLibrary.dll" #>
Source Code Transformations[Bearbeiten | Quelltext bearbeiten]
namespace $rootnamespace$.Models
{
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public string ContractId { get; set; }
}
}
XML Document Transformation (XDT Transform)[Bearbeiten | Quelltext bearbeiten]
|