summaryrefslogtreecommitdiff
path: root/src/internal/WixBuildTools.MsgGen/build/WixBuildTools.MsgGen.targets
blob: dfa7bcbea1e630a4a6152de57d7787bf194817c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?xml version="1.0" encoding="utf-8"?>
<!-- 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. -->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup>
    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
  </PropertyGroup>

  <ItemGroup>
    <!--Provide support for setting type (BuildAction) from VS-->
    <AvailableItemName Include="MsgGenSource" />
  </ItemGroup>

  <PropertyGroup>
    <MsgGenPath Condition=" '$(MsgGenPath)'=='' ">$(MSBuildThisFileDirectory)..\tools\</MsgGenPath>
  </PropertyGroup>

  <!--
  ================================================================================================
  MsgGen

    Generates a .cs class file and a .resx file from an XML file.

    [IN]
    @(MsgGenSource) - The items to run through the MsgGen tool.

    [OUT]
    $(IntermediateOutputPath)%(Filename).cs - The generated .cs files to include in the compilation.
    $(IntermediateOutputPath)%(MsgGenSource.ResourcesLogicalName) - The generated .resources file to embed in the assembly.
  ================================================================================================
  -->
  <PropertyGroup>
    <MsgGenDependsOn>
      PrepareMsgGen
    </MsgGenDependsOn>
    <PrepareResourcesDependsOn>
      MsgGen;
      $(PrepareResourcesDependsOn)
    </PrepareResourcesDependsOn>
  </PropertyGroup>
  <Target
    Name="MsgGen"
    BeforeTargets="PrepareResources"
    DependsOnTargets="$(MsgGenDependsOn)"
    Condition=" '@(MsgGenSource)' != '' "
    Inputs="@(MsgGenSource)"
    Outputs="$(IntermediateOutputPath)%(MsgGenSource.Filename).cs;
             $(IntermediateOutputPath)%(MsgGenSource.ResourcesLogicalName)">

    <Exec Command="&quot;$(MsgGenPath)WixBuildTools.MsgGen.exe&quot; -nologo &quot;%(MsgGenSource.FullPath)&quot; &quot;$(MsgGenCsFile)&quot; &quot;$(MsgGenResourcesFile)&quot;"
          Outputs="$(MsgGenCsFile);$(MsgGenResourcesFile)" />

    <ItemGroup>
      <!-- This will tell MSBuild to clean up the .cs and .resources file during a Clean build -->
      <FileWrites Include="$(MsgGenCsFile);$(MsgGenResourcesFile)" />
    </ItemGroup>
  </Target>

  <!--
  ================================================================================================
  PrepareMsgGen

    Creates properties and Include items for MsgGen. This must be separate from the MsgGen target
    to workaround an MSBuild bug: AdditionalMetadata is ignored when the target is up-to-date.

  ================================================================================================
  -->
  <Target
    Name="PrepareMsgGen"
    Condition=" '@(MsgGenSource)' != '' ">

    <CreateProperty Value="$(IntermediateOutputPath)%(MsgGenSource.Filename).cs">
      <Output TaskParameter="Value" PropertyName="MsgGenCsFile" />
    </CreateProperty>

    <CreateProperty
      Value="$(IntermediateOutputPath)%(MsgGenSource.ResourcesLogicalName)"
      Condition=" '%(MsgGenSource.ResourcesLogicalName)' != '' ">

      <Output TaskParameter="Value" PropertyName="MsgGenResourcesFile" />
    </CreateProperty>

    <!-- Add the generated .cs file to the list of source files to compile -->
    <CreateItem
      Include="$(MsgGenCsFile)"
      AdditionalMetadata="Link=%(MsgGenCsFile.Filename)%(MsgGenCsFile.Extension)">

      <Output TaskParameter="Include" ItemName="Compile" />
    </CreateItem>

    <!-- Add the generated .resources file to the list of resources to embed -->
    <CreateItem
      Include="$(MsgGenResourcesFile)"
      AdditionalMetadata="Link=%(MsgGenResourcesFile.Filename)%(MsgGenResourcesFile.Extension);
                          LogicalName=%(MsgGenSource.ResourcesLogicalName)"
      Condition=" '$(MsgGenResourcesFile)' != '' ">

      <Output TaskParameter="Include" ItemName="EmbeddedResource" />
    </CreateItem>
  </Target>

</Project>