|
4 | 4 | <PropertyGroup> |
5 | 5 | <MicroBuildCoreVersion>0.2.0</MicroBuildCoreVersion> |
6 | 6 | </PropertyGroup> |
7 | | -
|
| 7 | + |
8 | 8 | <ImportProject="..\packages\MicroBuild.Core.$(MicroBuildCoreVersion)\build\MicroBuild.Core.props" /> |
9 | | - |
10 | | - <UsingTaskTaskName="LocalizeTemplateProjectsTask"TaskFactory="CodeTaskFactory"AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> |
11 | | - <ParameterGroup> |
12 | | - <OutDirParameterType="System.String"Required="true" /> |
13 | | - <TemplateCategoryParameterType="System.String"Required="true" /> |
14 | | - <AssemblyNameParameterType="System.String"Required="true" /> |
15 | | - <TemplateFilesParameterType="System.String[]"Required="true" /> |
16 | | - <LocalizedFilesParameterType="System.String[]"Required="true" /> |
17 | | - <LocLanguagesParameterType="System.String"Required="true" /> |
18 | | - </ParameterGroup> |
19 | | - |
20 | | - <Task> |
21 | | - <ReferenceInclude="System.IO.Compression.FileSystem"/> |
22 | | - |
23 | | - <UsingNamespace="System"/> |
24 | | - <UsingNamespace="System.IO"/> |
25 | | - <UsingNamespace="System.IO.Compression"/> |
26 | | - |
27 | | - <CodeType="Fragment"Language="cs"> |
28 | | -<![CDATA[ |
29 | | - Log.LogMessage("Localizing template: " + AssemblyName, MessageImportance.High); |
30 | | - Log.LogMessage(String.Empty, MessageImportance.High); |
31 | | - var absoluteOutDir = Path.GetFullPath(OutDir); |
32 | | -
|
33 | | - foreach (var lang in LocLanguages.Split(',')) |
34 | | - { |
35 | | - var isDefaultLocale = lang.ToUpper() == "ENU"; |
36 | | -
|
37 | | - Log.LogMessage("---------------------------------------------------", MessageImportance.High); |
38 | | - Log.LogMessage("Localizing template for language: " + lang, MessageImportance.High); |
39 | | - Log.LogMessage(String.Empty, MessageImportance.High); |
40 | | -
|
41 | | - var tempZipFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); |
42 | | - Log.LogMessage("Copying template files to: " + tempZipFolder, MessageImportance.High); |
43 | | - Directory.CreateDirectory(tempZipFolder); |
44 | | -
|
45 | | - foreach (var sourceFile in TemplateFiles) |
46 | | - { |
47 | | - var destinationFile = Path.Combine(tempZipFolder, new FileInfo(sourceFile).Name); |
48 | | - File.Copy(sourceFile, destinationFile); |
49 | | - Log.LogMessage(" > Copied: " + destinationFile, MessageImportance.High); |
50 | | - } |
51 | | -
|
52 | | - if (isDefaultLocale) |
53 | | - { |
54 | | - Log.LogMessage("Skipping localized files (default locale)", MessageImportance.High); |
55 | | - } |
56 | | - else |
57 | | - { |
58 | | - Log.LogMessage("Copying localized files", MessageImportance.High); |
59 | | -
|
60 | | - foreach (var localizedFileItem in LocalizedFiles) |
61 | | - { |
62 | | - var fileName = new FileInfo(localizedFileItem).Name; |
63 | | - var sourceFile = Path.Combine(absoluteOutDir, "localize", lang, TemplateCategory, AssemblyName, fileName); |
64 | | - var destinationFile = Path.Combine(tempZipFolder, fileName); |
65 | | -
|
66 | | - if (File.Exists(sourceFile) == false) |
67 | | - { |
68 | | - throw new FileNotFoundException("Localized file not found: " + sourceFile, sourceFile); |
69 | | - } |
70 | | -
|
71 | | - File.Delete(destinationFile); |
72 | | - File.Copy(sourceFile, destinationFile); |
73 | | - Log.LogMessage(" > Copied: " + destinationFile, MessageImportance.High); |
74 | | - } |
75 | | - } |
76 | | -
|
77 | | - var templateOutputPath = isDefaultLocale |
78 | | - ? Path.Combine(absoluteOutDir, TemplateCategory, AssemblyName) |
79 | | - : Path.Combine(absoluteOutDir, "localize", lang, TemplateCategory, AssemblyName); |
80 | | -
|
81 | | - if (Directory.Exists(templateOutputPath) == false) |
82 | | - { |
83 | | - Directory.CreateDirectory(templateOutputPath); |
84 | | - } |
85 | | -
|
86 | | - var templateOutputFile = Path.Combine(templateOutputPath, AssemblyName + ".zip"); |
87 | | -
|
88 | | - if (File.Exists(templateOutputFile)) |
89 | | - { |
90 | | - File.Delete(templateOutputFile); |
91 | | - } |
92 | | -
|
93 | | - Log.LogMessage("Zipping template to: " + templateOutputFile, MessageImportance.High); |
94 | | - ZipFile.CreateFromDirectory(tempZipFolder, templateOutputFile); |
95 | | - Directory.Delete(tempZipFolder, true); |
96 | | -
|
97 | | - Log.LogMessage("---------------------------------------------------", MessageImportance.High); |
98 | | - Log.LogMessage(string.Empty, MessageImportance.High); |
99 | | - } |
100 | | -]]> |
101 | | - </Code> |
102 | | - </Task> |
103 | | - </UsingTask> |
104 | | - |
| 9 | + |
105 | 10 | <UsingTaskTaskName="GenerateAssemblyFileVersionTask"TaskFactory="CodeTaskFactory"AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> |
106 | 11 | <ParameterGroup> |
107 | 12 | <LanguageParameterType="System.String"Required="true" /> |
|
172 | 77 | </Code> |
173 | 78 | </Task> |
174 | 79 | </UsingTask> |
175 | | - |
176 | | -<!-- In case of a microbuild, depend on 'Localize' target to use the localized resources--> |
177 | | - <TargetName="LocalizeTemplateProjectsInMicrobuild"AfterTargets="Localize"Condition="'$(GenerateLocalizedTemplates)' == 'true' and '$(Languages)' != '' and '@(FilesToLocalize)' != ''"> |
178 | | - <LocalizeTemplateProjectsTask |
179 | | -OutDir="$(OutputPath)" |
180 | | -TemplateCategory="$(TemplateCategory)" |
181 | | -AssemblyName="$(AssemblyName)" |
182 | | -TemplateFiles="@(TemplateFiles)" |
183 | | -LocalizedFiles="@(FilesToLocalize)" |
184 | | -LocLanguages="$(Languages)" /> |
185 | | - </Target> |
186 | | - |
187 | | -<!-- In case of a local build, depend on the build target to use the native resources--> |
188 | | - <TargetName="LocalizeTemplateProjectsLocally"AfterTargets="Build"Condition="'$(GenerateLocalizedTemplates)' == 'true' and ('$(Languages)' == '' or '@(FilesToLocalize)' == '')"> |
189 | | - <PropertyGroup> |
190 | | - <LanguagesCondition="'$(Languages)' == ''">ENU</Languages> |
191 | | - </PropertyGroup> |
192 | | - |
193 | | - <LocalizeTemplateProjectsTask |
194 | | -OutDir="$(OutputPath)" |
195 | | -TemplateCategory="$(TemplateCategory)" |
196 | | -AssemblyName="$(AssemblyName)" |
197 | | -TemplateFiles="@(TemplateFiles)" |
198 | | -LocalizedFiles="@(FilesToLocalize)" |
199 | | -LocLanguages="$(Languages)" /> |
200 | | - </Target> |
201 | | - |
| 80 | + |
202 | 81 | <TargetName="GenerateAssemblyFileVersion"BeforeTargets="CoreCompile"> |
203 | 82 | <!-- Put build number 0 and today's date if this was a local build--> |
204 | 83 | <PropertyGroup> |
|