1 <?xml version="1.0" encoding="utf-8"?>
2 <Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <UsingTask TaskName="GenerateResourcesCode" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" />
4 <UsingTask TaskName="NormalizeAssemblyName" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" />
7 <GenerateResourceMSBuildRuntime>CurrentRuntime</GenerateResourceMSBuildRuntime>
8 <GenerateResourceMSBuildArchitecture>CurrentArchitecture</GenerateResourceMSBuildArchitecture>
12 <ResourcesSourceOutputDirectory Condition="'$(ResourcesSourceOutputDirectory)' == ''">$(MSBuildProjectDirectory)/Resources/</ResourcesSourceOutputDirectory>
13 <StringResourcesPath Condition="'$(StringResourcesPath)'=='' And Exists('$(ResourcesSourceOutputDirectory)Strings.resx')">$(ResourcesSourceOutputDirectory)Strings.resx</StringResourcesPath>
14 <IntermediateResOutputFileFullPath Condition="'$(MSBuildProjectExtension)' == '.csproj'">$(IntermediateOutputPath)SR.cs</IntermediateResOutputFileFullPath>
15 <IntermediateResOutputFileFullPath Condition="'$(MSBuildProjectExtension)' == '.vbproj'">$(IntermediateOutputPath)SR.vb</IntermediateResOutputFileFullPath>
16 <DefineConstants Condition="'$(ConfigurationGroup)' == 'Debug'">$(DefineConstants);DEBUGRESOURCES</DefineConstants>
19 <PropertyGroup Condition="'$(BuildingUAPVertical)' == 'true'">
21 CopyResxFilesToReswFiles;
26 <Target Name="CalculateResourcesFileNames" Condition="'$(BuildingUAPVertical)' == 'true'">
28 <_AllResxFiles Include="@(EmbeddedResource->'%(FullPath)')" Condition="'%(Extension)' == '.resx'">
29 <ReswName Condition="'%(EmbeddedResource.ReswName)' == ''">%(EmbeddedResource.ManifestResourceName)</ReswName>
34 <ProjectHasResources Condition="'@(_AllResxFiles)' != ''">true</ProjectHasResources>
35 <TestProjectNeedsModifiedPriFile Condition="'$(IsTestProject)' == 'true' AND '$(ProjectHasResources)' == 'true'">true</TestProjectNeedsModifiedPriFile>
36 <TestResourcesFolderPath Condition="'$(TestProjectNeedsModifiedPriFile)' == 'true'">$(RuntimePath)$(AssemblyName).Resw</TestResourcesFolderPath>
37 <_ResWDestinationPath Condition="'$(TestResourcesFolderPath)' != ''">$(TestResourcesFolderPath)</_ResWDestinationPath>
38 <_ResWDestinationPath Condition="'$(TestResourcesFolderPath)' == ''">$(ResourcesFolderPath)</_ResWDestinationPath>
42 <_ReswOutputFiles Include="@(_AllResxFiles->'$(_ResWDestinationPath)/%(ReswName).resw')" />
47 <Target Name="CopyResxFilesToReswFiles"
48 Condition="'$(BuildingUAPVertical)' == 'true'"
49 DependsOnTargets="CalculateResourcesFileNames"
50 Inputs="@(_AllResxFiles)"
51 Outputs="@(_ReswOutputFiles)" >
53 <Copy SourceFiles="@(_AllResxFiles)"
54 DestinationFiles="@(_ReswOutputFiles)"
55 SkipUnchangedFiles="true">
56 <Output TaskParameter="CopiedFiles" ItemName="FilesCreated" />
59 <!-- We need to touch the copied files so that the target that uses them can track the inputs and outputs with the copied timestamp -->
60 <Touch Files="@(FilesCreated)" />
64 <PropertyGroup Condition="'$(StringResourcesPath)'!=''">
66 NormalizeAssemblyName;
67 GenerateResourcesSource;
72 <Target Name="NormalizeAssemblyName" Condition="'$(StringResourcesPath)'!='' AND '$(OmitResources)'!='true'">
73 <NormalizeAssemblyName
74 AssemblyName="$(AssemblyName)" >
75 <Output TaskParameter="NormalizedAssemblyName" PropertyName="_NormalizedAssemblyName" />
76 </NormalizeAssemblyName>
80 EmbeddedResource is defined outside the target and cannot be defined inside this target
81 we need to update logical name and ReswName after we normalize the assembly name.
83 <EmbeddedResource Condition="'%(EmbeddedResource.LogicalName)'=='FxResources.$(AssemblyName).SR.resources'">
84 <LogicalName>FxResources.$(_NormalizedAssemblyName).SR.resources</LogicalName>
85 <ReswName Condition="'$(BuildingUAPVertical)' == 'true'">FxResources.$(_NormalizedAssemblyName).SR</ReswName>
90 <Target Name="GenerateResourcesSource" DependsOnTargets="NormalizeAssemblyName"
91 Condition="'$(StringResourcesPath)'!='' AND '$(OmitResources)'!='true'"
92 Inputs="$(StringResourcesPath)"
93 Outputs="$(IntermediateResOutputFileFullPath)">
95 <GenerateResourcesCode
96 ResxFilePath="$(StringResourcesPath)"
97 OutputSourceFilePath="$(IntermediateResOutputFileFullPath)"
98 AssemblyName="$(_NormalizedAssemblyName)"
99 SRNamespace="$(GenerateResourcesSRNamespace)"
100 SRClassName="$(GenerateResourcesSRClassName)"
101 ResourcesNamespace="$(GenerateResourcesResourcesNamespace)"
102 ResourcesClassName="$(GenerateResourcesResourcesClassName)"
103 AsConstants="$(GenerateResourcesCodeAsConstants)">
104 </GenerateResourcesCode>
107 <!-- The following Compile element has to be included dynamically inside the Target otherwise intellisense will not work -->
108 <Compile Include="$(IntermediateResOutputFileFullPath)" />
112 <FileWrites Include="$(IntermediateResOutputFileFullPath)" />
116 <ItemGroup Condition="'$(StringResourcesPath)'!='' AND '$(OmitResources)'!='true'">
117 <EmbeddedResource Include="$(StringResourcesPath)">
118 <Visible>true</Visible>
119 <LogicalName>FxResources.$(AssemblyName).SR.resources</LogicalName>
120 <ReswName Condition="'$(BuildingUAPVertical)' == 'true'">FxResources.$(AssemblyName).SR</ReswName>
121 <!-- Set the Generator metadata so that VS triggers design-time build whenever the .resx file is saved -->
122 <Generator>MSBuild:GenerateResourcesSource</Generator>
127 <When Condition="Exists('$(StringResourcesPath)') And '$(SkipCommonResourcesIncludes)'=='' AND '$(OmitResources)'!='true'">
129 <When Condition="'$(MSBuildProjectExtension)' == '.csproj'">
131 <Compile Include="$(CommonPath)/System/SR.cs">
132 <Visible>true</Visible>
133 <Link>Resources/Common/SR.cs</Link>
137 <When Condition="'$(MSBuildProjectExtension)' == '.vbproj'">
139 <Compile Include="$(CommonPath)/System/SR.vb">
140 <Visible>true</Visible>
141 <Link>Resources/Common/SR.vb</Link>