| 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> |
| 3 | |
| 4 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> |
| 5 | <ItemGroup> |
| 6 | <!--Provide support for setting type (BuildAction) from VS--> |
| 7 | <AvailableItemName Include="MsgGenSource" /> |
| 8 | </ItemGroup> |
| 9 | |
| 10 | <PropertyGroup> |
| 11 | <MsgGenPath Condition=" '$(MsgGenPath)'=='' ">$(MSBuildThisFileDirectory)..\tools\</MsgGenPath> |
| 12 | </PropertyGroup> |
| 13 | |
| 14 | <!-- |
| 15 | ================================================================================================ |
| 16 | MsgGen |
| 17 | |
| 18 | Generates a .cs class file and a .resx file from an XML file. |
| 19 | |
| 20 | [IN] |
| 21 | @(MsgGenSource) - The items to run through the MsgGen tool. |
| 22 | |
| 23 | [OUT] |
| 24 | $(IntermediateOutputPath)%(Filename).cs - The generated .cs files to include in the compilation. |
| 25 | $(IntermediateOutputPath)%(MsgGenSource.ResourcesLogicalName) - The generated .resources file to embed in the assembly. |
| 26 | ================================================================================================ |
| 27 | --> |
| 28 | <PropertyGroup> |
| 29 | <MsgGenDependsOn> |
| 30 | PrepareMsgGen |
| 31 | </MsgGenDependsOn> |
| 32 | <PrepareResourcesDependsOn> |
| 33 | MsgGen; |
| 34 | $(PrepareResourcesDependsOn) |
| 35 | </PrepareResourcesDependsOn> |
| 36 | </PropertyGroup> |
| 37 | <Target |
| 38 | Name="MsgGen" |
| 39 | BeforeTargets="PrepareResources" |
| 40 | DependsOnTargets="$(MsgGenDependsOn)" |
| 41 | Condition=" '@(MsgGenSource)' != '' " |
| 42 | Inputs="@(MsgGenSource)" |
| 43 | Outputs="$(IntermediateOutputPath)%(MsgGenSource.Filename).cs; |
| 44 | $(IntermediateOutputPath)%(MsgGenSource.ResourcesLogicalName)"> |
| 45 | |
| 46 | <Exec Command=""$(MsgGenPath)WixBuildTools.MsgGen.exe" -nologo "%(MsgGenSource.FullPath)" "$(MsgGenCsFile)" "$(MsgGenResourcesFile)"" |
| 47 | Outputs="$(MsgGenCsFile);$(MsgGenResourcesFile)" /> |
| 48 | |
| 49 | <ItemGroup> |
| 50 | <!-- This will tell MSBuild to clean up the .cs and .resources file during a Clean build --> |
| 51 | <FileWrites Include="$(MsgGenCsFile);$(MsgGenResourcesFile)" /> |
| 52 | </ItemGroup> |
| 53 | </Target> |
| 54 | |
| 55 | <!-- |
| 56 | ================================================================================================ |
| 57 | PrepareMsgGen |
| 58 | |
| 59 | Creates properties and Include items for MsgGen. This must be separate from the MsgGen target |
| 60 | to workaround an MSBuild bug: AdditionalMetadata is ignored when the target is up-to-date. |
| 61 | |
| 62 | ================================================================================================ |
| 63 | --> |
| 64 | <Target |
| 65 | Name="PrepareMsgGen" |
| 66 | Condition=" '@(MsgGenSource)' != '' "> |
| 67 | |
| 68 | <CreateProperty Value="$(IntermediateOutputPath)%(MsgGenSource.Filename).cs"> |
| 69 | <Output TaskParameter="Value" PropertyName="MsgGenCsFile" /> |
| 70 | </CreateProperty> |
| 71 | |
| 72 | <CreateProperty |
| 73 | Value="$(IntermediateOutputPath)%(MsgGenSource.ResourcesLogicalName)" |
| 74 | Condition=" '%(MsgGenSource.ResourcesLogicalName)' != '' "> |
| 75 | |
| 76 | <Output TaskParameter="Value" PropertyName="MsgGenResourcesFile" /> |
| 77 | </CreateProperty> |
| 78 | |
| 79 | <!-- Add the generated .cs file to the list of source files to compile --> |
| 80 | <CreateItem |
| 81 | Include="$(MsgGenCsFile)" |
| 82 | AdditionalMetadata="Link=%(MsgGenCsFile.Filename)%(MsgGenCsFile.Extension)"> |
| 83 | |
| 84 | <Output TaskParameter="Include" ItemName="Compile" /> |
| 85 | </CreateItem> |
| 86 | |
| 87 | <!-- Add the generated .resources file to the list of resources to embed --> |
| 88 | <CreateItem |
| 89 | Include="$(MsgGenResourcesFile)" |
| 90 | AdditionalMetadata="Link=%(MsgGenResourcesFile.Filename)%(MsgGenResourcesFile.Extension); |
| 91 | LogicalName=%(MsgGenSource.ResourcesLogicalName)" |
| 92 | Condition=" '$(MsgGenResourcesFile)' != '' "> |
| 93 | |
| 94 | <Output TaskParameter="Include" ItemName="EmbeddedResource" /> |
| 95 | </CreateItem> |
| 96 | </Target> |
| 97 | |
| 98 | </Project> |