Skip to content

Commit c8507f3

Browse files
committed
Parameterize Product details
1 parent eee78e9 commit c8507f3

21 files changed

+249
-89
lines changed

Diff for: FSharpBuild.Directory.Build.targets

+54-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,43 @@
11
<Project>
2+
23
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
34
<Import Project="eng\targets\Imports.targets" />
45
<Import Project="eng\targets\NuGet.targets" />
56
<Import Project="eng\targets\NGenBinaries.targets" />
67
<Import Project="FSharp.Profiles.props" />
78

9+
<Target Name="_GenerateBuildPropertiesFile"
10+
Outputs="$(IntermediateOutputPath)buildproperties.fs"
11+
BeforeTargets="BeforeBuild"
12+
Condition="'$(Language)'=='F#'">
13+
14+
<ItemGroup>
15+
<_BuildPropertyLines Remove="@(_BuildPropertyLines)" />
16+
<_BuildPropertyLines Include="// &lt;auto-generated &gt;" />
17+
<_BuildPropertyLines Include="// &lt;Generated by the FSharp WriteCodeFragment class./&gt;" />
18+
<_BuildPropertyLines Include="// &lt;/auto-generated/&gt;" />
19+
<_BuildPropertyLines Include="//" />
20+
<_BuildPropertyLines Include="module internal FSharp.BuildProperties" />
21+
<_BuildPropertyLines Include="let fsProductVersion = &quot;$(FSPRODUCTVERSION)&quot;" />
22+
<_BuildPropertyLines Include="let fsLanguageVersion = &quot;$(FSLANGUAGEVERSION)&quot;" />
23+
</ItemGroup>
24+
25+
<MakeDir
26+
Directories="$(IntermediateOutputPath)"
27+
Condition="!Exists('$(IntermediateOutputPath)')" />
28+
<WriteLinesToFile File="$(IntermediateOutputPath)buildproperties.fs" Lines="@(_BuildPropertyLines)" Overwrite="true" WriteOnlyWhenDifferent="true" />
29+
30+
<!-- Make sure it will get cleaned -->
31+
<ItemGroup>
32+
<FileWrites Include="$(IntermediateOutputPath)buildproperties.fs" />
33+
<CompileBefore Include="$(IntermediateOutputPath)buildproperties.fs" />
34+
</ItemGroup>
35+
</Target>
36+
837
<Target Name="NoneSubstituteTextFiles"
938
Inputs="@(NoneSubstituteText)"
1039
Outputs="@(NoneSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')"
11-
BeforeTargets="AssignTargetPaths;BeforeBuild">
40+
BeforeTargets="AssignTargetPaths;BeforeBuild;GenerateFSharpTextResources">
1241

1342
<PropertyGroup>
1443
<__TargetFilePath>@(NoneSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')</__TargetFilePath>
@@ -27,7 +56,7 @@
2756
<WriteLinesToFile File="$(__TargetFilePath)" Lines="$(_ReplacementText)" Overwrite="true" WriteOnlyWhenDifferent="true" />
2857

2958
<!-- Make sure it will get cleaned -->
30-
<ItemGroup >
59+
<ItemGroup>
3160
<None Include="$(__TargetFilePath)" CopyToOutputDirectory="$(_CopyToOutputDirectory)" />
3261
<FileWrites Include="$(__TargetFilePath)" Condition="'$(__TargetFileName)' != 'App.config'" />
3362
</ItemGroup>
@@ -61,4 +90,27 @@
6190
</ItemGroup>
6291
</Target>
6392

93+
<Target Name="BeforeResGen"
94+
Inputs="@(EmbeddedResource->'$(IntermediateOutputPath)%(Filename)%(Extension)')"
95+
Outputs="@(EmbeddedResource->'$(IntermediateOutputPath)resources\%(Filename)%(Extension)')"
96+
DependsOnTargets="CopyVsixResources"
97+
Condition="'$(Configuration)' != 'Proto' and '$(Language)'=='F#'">
98+
<SubstituteText EmbeddedResources="@(EmbeddedResource)">
99+
<Output TaskParameter="CopiedFiles" ItemName="CopiedFiles" />
100+
</SubstituteText>
101+
102+
<Message Text="CopiedFiles: '@(CopiedFiles)'" />
103+
<ItemGroup>
104+
<EmbeddedResource Remove="@(EmbeddedResource)"/>
105+
<EmbeddedResource Include="@(CopiedFiles)"/>
106+
</ItemGroup>
107+
108+
<MakeDir Directories="$(IntermediateOutputPath)" Condition="!Exists('$(IntermediateOutputPath)')" />
109+
<MakeDir Directories="$(IntermediateOutputPath)resources\" Condition="!Exists('$(IntermediateOutputPath)resources\')" />
110+
</Target>
111+
112+
<Target Name="CopyVsixResources">
113+
<Copy SourceFiles="@(CopyVsixResources)" DestinationFolder="$(IntermediateOutputPath)\resources\Resources" />
114+
</Target>
115+
64116
</Project>

Diff for: src/fsharp/FSharp.Build/FSharp.Build.fsproj

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<Compile Include="FSharpEmbedResXSource.fs" />
2727
<Compile Include="WriteCodeFragment.fs" />
2828
<Compile Include="CreateFSharpManifestResourceName.fs" />
29+
<Compile Include="SubstituteText.fs" />
2930
<None Include="Microsoft.FSharp.Targets" CopyToOutputDirectory="PreserveNewest" />
3031
<None Include="Microsoft.Portable.FSharp.Targets" CopyToOutputDirectory="PreserveNewest" />
3132
<None Include="Microsoft.FSharp.NetSdk.targets" CopyToOutputDirectory="PreserveNewest" />

Diff for: src/fsharp/FSharp.Build/Microsoft.FSharp.Targets

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ this file.
2929
<UsingTask TaskName="CreateFSharpManifestResourceName" AssemblyFile="$(FSharpBuildAssemblyFile)" />
3030
<UsingTask TaskName="WriteCodeFragment" AssemblyFile="$(FSharpBuildAssemblyFile)" />
3131
<UsingTask TaskName="FSharpPlatformInformation" AssemblyFile="$(FSharpBuildAssemblyFile)" />
32+
<UsingTask TaskName="SubstituteText" AssemblyFile="$(FSharpBuildAssemblyFile)" />
3233

3334
<PropertyGroup>
3435
<ImportByWildcardBeforeMicrosoftFSharpTargets Condition="'$(ImportByWildcardBeforeMicrosoftFSharpTargets)' == ''">true</ImportByWildcardBeforeMicrosoftFSharpTargets>

Diff for: src/fsharp/FSharp.Build/SubstituteText.fs

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
3+
namespace FSharp.Build
4+
5+
open System
6+
open System.Collections
7+
open System.IO
8+
open Microsoft.Build.Framework
9+
open Microsoft.Build.Utilities
10+
11+
type SubstituteText () =
12+
13+
let mutable _buildEngine : IBuildEngine = null
14+
let mutable _hostObject : ITaskHost = null
15+
16+
let mutable copiedFiles = new ResizeArray<ITaskItem>()
17+
let mutable embeddedResources : ITaskItem[] = [||]
18+
19+
[<Required>]
20+
member this.EmbeddedResources
21+
with get() = embeddedResources
22+
and set(value) = embeddedResources <- value
23+
24+
[<Output>]
25+
member this.CopiedFiles
26+
with get() = copiedFiles.ToArray()
27+
28+
interface ITask with
29+
member this.BuildEngine
30+
with get() = _buildEngine
31+
and set(value) = _buildEngine <- value
32+
33+
member this.HostObject
34+
with get() = _hostObject
35+
and set(value) = _hostObject <- value
36+
37+
member this.Execute() =
38+
copiedFiles.Clear()
39+
if not(isNull embeddedResources) then
40+
for item in embeddedResources do
41+
// Update ITaskItem metadata to point to new location
42+
let sourcePath = item.GetMetadata("FullPath")
43+
44+
let pattern1 = item.GetMetadata("Pattern1")
45+
let pattern2 = item.GetMetadata("Pattern2")
46+
47+
// Is there any replacement to do?
48+
if not (String.IsNullOrWhiteSpace(pattern1) && String.IsNullOrWhiteSpace(pattern2)) then
49+
if not(String.IsNullOrWhiteSpace(sourcePath)) then
50+
try
51+
let getTargetPathFrom key =
52+
let md = item.GetMetadata(key)
53+
let path = Path.GetDirectoryName(md)
54+
let filename = Path.GetFileName(md)
55+
let target = Path.Combine(path, @"..\resources", filename)
56+
target
57+
58+
// Copy from the location specified in Identity
59+
let sourcePath=item.GetMetadata("Identity")
60+
61+
// Copy to the location specified in TargetPath unless no TargetPath is provided, then use Identity
62+
let targetPath=
63+
let identityPath = getTargetPathFrom "Identity"
64+
let intermediateTargetPath = item.GetMetadata("IntermediateTargetPath")
65+
if not (String.IsNullOrWhiteSpace(intermediateTargetPath)) then
66+
let filename = Path.GetFileName(identityPath)
67+
let target = Path.Combine(intermediateTargetPath, filename)
68+
target
69+
else
70+
identityPath
71+
72+
item.ItemSpec <- targetPath
73+
74+
// Transform file
75+
let mutable contents = File.ReadAllText(sourcePath)
76+
if not (String.IsNullOrWhiteSpace(pattern1)) then
77+
let replacement = item.GetMetadata("Replacement1")
78+
contents <- contents.Replace(pattern1, replacement)
79+
if not (String.IsNullOrWhiteSpace(pattern2)) then
80+
let replacement = item.GetMetadata("Replacement2")
81+
contents <- contents.Replace(pattern2, replacement)
82+
83+
let directory = Path.GetDirectoryName(targetPath)
84+
if not(Directory.Exists(directory)) then
85+
Directory.CreateDirectory(directory) |>ignore
86+
87+
File.WriteAllText(targetPath, contents)
88+
with
89+
| _ -> ()
90+
91+
copiedFiles.Add(item)
92+
true

Diff for: vsintegration/Vsix/RegisterFsharpPackage.pkgdef

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"1"="{92EF0900-2251-11D2-B72E-0000F87572EF}"
5656

5757
[$RootKey$\Packages\{91a04a73-4f2c-4e7c-ad38-c1a68e7da05c}]
58-
"ProductVersion"="10.4"
58+
"ProductVersion"="{{FSProductVersion}}"
5959
"ProductName"="Visual F#"
6060
"CompanyName"="Microsoft Corp."
6161

Diff for: vsintegration/Vsix/VisualFSharpFull/VisualFSharpFull.csproj

+10-5
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@
1414
<None Include="Source.extension.vsixmanifest">
1515
<SubType>Designer</SubType>
1616
</None>
17-
<Content Include="..\RegisterFsharpPackage.pkgdef">
18-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
19-
<IncludeInVSIX>true</IncludeInVSIX>
20-
<Link>RegisterFsharpPackage.pkgdef</Link>
21-
</Content>
17+
18+
<NoneSubstituteText Include="..\RegisterFsharpPackage.pkgdef" CopyToOutputDirectory="PreserveNewest">
19+
<TargetFileName>RegisterFsharpPackage.pkgdef</TargetFileName>
20+
<Pattern1>{{FSProductVersion}}</Pattern1>
21+
<Replacement1>$(FSProductVersion)</Replacement1>
22+
<Pattern2>{{FSLanguageVersion}}</Pattern2>
23+
<Replacement2>$(FSLanguageVersion)</Replacement2>
24+
</NoneSubstituteText>
25+
2226
<Content Include="$(FSharpSourcesRoot)\..\License.txt">
2327
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2428
<Link>License.txt</Link>
2529
<IncludeInVSIX>true</IncludeInVSIX>
2630
</Content>
31+
2732
<Content Include="$(NuGetPackageRoot)\Microsoft.VisualFSharp.Type.Providers.Redist\$(MicrosoftVisualFSharpTypeProvidersRedistVersion)\content\$(FSharpDataTypeProvidersVersion)\FSharp.Data.TypeProviders.dll">
2833
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2934
<Link>FSharp.Data.TypeProviders.dll</Link>

Diff for: vsintegration/src/FSharp.ProjectSystem.FSharp/ProjectSystem.fsproj

+9
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,22 @@
2424
<ResourceName>Menus.ctmenu</ResourceName>
2525
<SubType>Designer</SubType>
2626
</VSCTCompile>
27+
28+
<!-- Copy resx file and transform product/language version -->
29+
<CopyVsixResources Include="Resources/**" />
2730
<EmbeddedResource Include="VSPackage.resx">
2831
<GenerateSource>true</GenerateSource>
2932
<GeneratedModuleName>Microsoft.VisualStudio.FSharp.ProjectSystem.FSharpSR</GeneratedModuleName>
3033
<MergeWithCTO>true</MergeWithCTO>
3134
<ManifestResourceName>VSPackage</ManifestResourceName>
3235
<SubType>Designer</SubType>
36+
<IntermediateTargetPath>$(IntermediateOutputPath)resources\</IntermediateTargetPath>
37+
<Pattern1>{{FSProductVersion}}</Pattern1>
38+
<Replacement1>$(FSProductVersion)</Replacement1>
39+
<Pattern2>{{FSLanguageVersion}}</Pattern2>
40+
<Replacement2>$(FSLanguageVersion)</Replacement2>
3341
</EmbeddedResource>
42+
3443
<Compile Include="ProjectPrelude.fs" />
3544
<Compile Include="WaitDialog.fs" />
3645
<Compile Include="MSBuildUtilities.fs" />

Diff for: vsintegration/src/FSharp.ProjectSystem.FSharp/VSPackage.resx

+3-3
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,10 @@
464464
<value>Customizes the environment to maximize code editor screen space and improve the visibility of F# commands and tool windows.</value>
465465
</data>
466466
<data name="ProductDetails" xml:space="preserve">
467-
<value>Microsoft Visual F# Tools 10.4 for F# 4.6</value>
467+
<value>Microsoft Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</value>
468468
</data>
469469
<data name="9002" xml:space="preserve">
470-
<value>Microsoft Visual F# Tools 10.4 for F# 4.6</value>
470+
<value>Microsoft Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</value>
471471
</data>
472472
<data name="ProductID" xml:space="preserve">
473473
<value>1.0</value>
@@ -476,7 +476,7 @@
476476
<value>Microsoft Visual F# Tools</value>
477477
</data>
478478
<data name="9001" xml:space="preserve">
479-
<value>Visual F# Tools 10.4 for F# 4.6</value>
479+
<value>Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</value>
480480
</data>
481481
<data name="9027" xml:space="preserve">
482482
<value>F# Interactive</value>

Diff for: vsintegration/src/FSharp.ProjectSystem.FSharp/xlf/VSPackage.cs.xlf

+6-6
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,13 @@
433433
<note />
434434
</trans-unit>
435435
<trans-unit id="ProductDetails">
436-
<source>Microsoft Visual F# Tools 10.4 for F# 4.6</source>
437-
<target state="translated">Nástroje Microsoft Visual F# 10.4 pro F# 4.6</target>
436+
<source>Microsoft Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</source>
437+
<target state="needs-review-translation">Nástroje Microsoft Visual F# {{FSProductVersion}} pro F# {{FSLanguageVersion}}</target>
438438
<note />
439439
</trans-unit>
440440
<trans-unit id="9002">
441-
<source>Microsoft Visual F# Tools 10.4 for F# 4.6</source>
442-
<target state="translated">Nástroje Microsoft Visual F# 10.4 pro F# 4.6</target>
441+
<source>Microsoft Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</source>
442+
<target state="needs-review-translation">Nástroje Microsoft Visual F# {{FSProductVersion}} pro F# {{FSLanguageVersion}}</target>
443443
<note />
444444
</trans-unit>
445445
<trans-unit id="ProductID">
@@ -453,8 +453,8 @@
453453
<note />
454454
</trans-unit>
455455
<trans-unit id="9001">
456-
<source>Visual F# Tools 10.4 for F# 4.6</source>
457-
<target state="translated">Nástroje Visual F# 10.4 pro F# 4.6</target>
456+
<source>Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</source>
457+
<target state="needs-review-translation">Nástroje Visual F# {{FSProductVersion}} pro F# {{FSLanguageVersion}}</target>
458458
<note />
459459
</trans-unit>
460460
<trans-unit id="9027">

Diff for: vsintegration/src/FSharp.ProjectSystem.FSharp/xlf/VSPackage.de.xlf

+6-6
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,13 @@
433433
<note />
434434
</trans-unit>
435435
<trans-unit id="ProductDetails">
436-
<source>Microsoft Visual F# Tools 10.4 for F# 4.6</source>
437-
<target state="translated">Microsoft Visual F# Tools 10.4 für f# 4.6</target>
436+
<source>Microsoft Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</source>
437+
<target state="needs-review-translation">Microsoft Visual F# Tools {{FSProductVersion}} für f# {{FSLanguageVersion}}</target>
438438
<note />
439439
</trans-unit>
440440
<trans-unit id="9002">
441-
<source>Microsoft Visual F# Tools 10.4 for F# 4.6</source>
442-
<target state="translated">Microsoft Visual F# Tools 10.4 für f# 4.6</target>
441+
<source>Microsoft Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</source>
442+
<target state="needs-review-translation">Microsoft Visual F# Tools {{FSProductVersion}} für f# {{FSLanguageVersion}}</target>
443443
<note />
444444
</trans-unit>
445445
<trans-unit id="ProductID">
@@ -453,8 +453,8 @@
453453
<note />
454454
</trans-unit>
455455
<trans-unit id="9001">
456-
<source>Visual F# Tools 10.4 for F# 4.6</source>
457-
<target state="translated">Visual F# Tools 10.4 für F# 4.6</target>
456+
<source>Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</source>
457+
<target state="needs-review-translation">Visual F# Tools {{FSProductVersion}} für F# {{FSLanguageVersion}}</target>
458458
<note />
459459
</trans-unit>
460460
<trans-unit id="9027">

Diff for: vsintegration/src/FSharp.ProjectSystem.FSharp/xlf/VSPackage.es.xlf

+6-6
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,13 @@
433433
<note />
434434
</trans-unit>
435435
<trans-unit id="ProductDetails">
436-
<source>Microsoft Visual F# Tools 10.4 for F# 4.6</source>
437-
<target state="translated">Herramientas de Microsoft Visual F# 10.4 para F# 4.6</target>
436+
<source>Microsoft Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</source>
437+
<target state="needs-review-translation">Herramientas de Microsoft Visual F# {{FSProductVersion}} para F# {{FSLanguageVersion}}</target>
438438
<note />
439439
</trans-unit>
440440
<trans-unit id="9002">
441-
<source>Microsoft Visual F# Tools 10.4 for F# 4.6</source>
442-
<target state="translated">Herramientas de Microsoft Visual F# 10.4 para F# 4.6</target>
441+
<source>Microsoft Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</source>
442+
<target state="needs-review-translation">Herramientas de Microsoft Visual F# {{FSProductVersion}} para F# {{FSLanguageVersion}}</target>
443443
<note />
444444
</trans-unit>
445445
<trans-unit id="ProductID">
@@ -453,8 +453,8 @@
453453
<note />
454454
</trans-unit>
455455
<trans-unit id="9001">
456-
<source>Visual F# Tools 10.4 for F# 4.6</source>
457-
<target state="translated">Visual F# Tools 10.4 para F# 4.6</target>
456+
<source>Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</source>
457+
<target state="needs-review-translation">Visual F# Tools {{FSProductVersion}} para F# {{FSLanguageVersion}}</target>
458458
<note />
459459
</trans-unit>
460460
<trans-unit id="9027">

Diff for: vsintegration/src/FSharp.ProjectSystem.FSharp/xlf/VSPackage.fr.xlf

+6-6
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,13 @@
433433
<note />
434434
</trans-unit>
435435
<trans-unit id="ProductDetails">
436-
<source>Microsoft Visual F# Tools 10.4 for F# 4.6</source>
437-
<target state="translated">Microsoft Visual F# Tools 10.4 pour F# 4.6</target>
436+
<source>Microsoft Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</source>
437+
<target state="needs-review-translation">Microsoft Visual F# Tools {{FSProductVersion}} pour F# {{FSLanguageVersion}}</target>
438438
<note />
439439
</trans-unit>
440440
<trans-unit id="9002">
441-
<source>Microsoft Visual F# Tools 10.4 for F# 4.6</source>
442-
<target state="translated">Microsoft Visual F# Tools 10.4 pour F# 4.6</target>
441+
<source>Microsoft Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</source>
442+
<target state="needs-review-translation">Microsoft Visual F# Tools {{FSProductVersion}} pour F# {{FSLanguageVersion}}</target>
443443
<note />
444444
</trans-unit>
445445
<trans-unit id="ProductID">
@@ -453,8 +453,8 @@
453453
<note />
454454
</trans-unit>
455455
<trans-unit id="9001">
456-
<source>Visual F# Tools 10.4 for F# 4.6</source>
457-
<target state="translated">Visual F# Tools 10.4 pour F# 4.6</target>
456+
<source>Visual F# Tools {{FSProductVersion}} for F# {{FSLanguageVersion}}</source>
457+
<target state="needs-review-translation">Visual F# Tools {{FSProductVersion}} pour F# {{FSLanguageVersion}}</target>
458458
<note />
459459
</trans-unit>
460460
<trans-unit id="9027">

0 commit comments

Comments
 (0)