Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit f54aa60

Browse files
KevinRansomnosami
authored andcommitted
Parameterize product version (dotnet#8031)
* Parameterize Product details * fcs * Repack pkgdef
1 parent 93ccbef commit f54aa60

22 files changed

+290
-90
lines changed

FSharpBuild.Directory.Build.targets

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<Project>
2+
3+
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
4+
<Import Project="eng\targets\Imports.targets" />
5+
<Import Project="eng\targets\NuGet.targets" />
6+
<Import Project="eng\targets\NGenBinaries.targets" />
7+
<Import Project="FSharp.Profiles.props" />
8+
9+
<Target Name="NoneSubstituteTextFiles"
10+
Inputs="@(NoneSubstituteText)"
11+
Outputs="@(NoneSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')"
12+
BeforeTargets="AssignTargetPaths;BeforeBuild;GenerateFSharpTextResources">
13+
14+
<PropertyGroup>
15+
<__TargetFilePath>@(NoneSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')</__TargetFilePath>
16+
<__TargetFileName>@(NoneSubstituteText->'%(Filename)%(Extension)')</__TargetFileName>
17+
18+
<_ReplacementText>$([System.IO.File]::ReadAllText('%(NoneSubstituteText.FullPath)'))</_ReplacementText>
19+
<_ReplacementText Condition="'%(NoneSubstituteText.Pattern1)' != ''">$(_ReplacementText.Replace('%(NoneSubstituteText.Pattern1)', '%(NoneSubstituteText.Replacement1)'))</_ReplacementText>
20+
<_ReplacementText Condition="'%(NoneSubstituteText.Pattern2)' != ''">$(_ReplacementText.Replace('%(NoneSubstituteText.Pattern2)', '%(NoneSubstituteText.Replacement2)'))</_ReplacementText>
21+
22+
<_CopyToOutputDirectory Condition="'%(NoneSubstituteText.CopyToOutputDirectory)' != ''">%(NoneSubstituteText.CopyToOutputDirectory)</_CopyToOutputDirectory>
23+
<_CopyToOutputDirectory Condition="'%(NoneSubstituteText.CopyToOutputDirectory)' == ''">Never</_CopyToOutputDirectory>
24+
25+
<_IncludeInVsix>false</_IncludeInVsix>
26+
<_IncludeInVsix Condition="'%(NoneSubstituteText.IncludeInVsix)' == 'true'">true</_IncludeInVsix>
27+
</PropertyGroup>
28+
29+
<MakeDir Directories="$(IntermediateOutputPath)"
30+
Condition="!Exists('$(IntermediateOutputPath)')" />
31+
<WriteLinesToFile File="$(__TargetFilePath)" Lines="$(_ReplacementText)" Overwrite="true" WriteOnlyWhenDifferent="true" />
32+
33+
<ItemGroup>
34+
<None Include="$(__TargetFilePath)" CopyToOutputDirectory="$(_CopyToOutputDirectory)" />
35+
<FileWrites Include="$(__TargetFilePath)" Condition="'$(__TargetFileName)' != 'App.config'" />
36+
<Content Include="$(__TargetFilePath)" CopyToOutputDirectory="Always" IncludeInVsix="true" />
37+
</ItemGroup>
38+
</Target>
39+
40+
<Target Name="_GenerateBuildPropertiesFile"
41+
Outputs="$(IntermediateOutputPath)buildproperties.fs"
42+
BeforeTargets="BeforeBuild"
43+
Condition="'$(Language)'=='F#'">
44+
45+
<ItemGroup>
46+
<_BuildPropertyLines Remove="@(_BuildPropertyLines)" />
47+
<_BuildPropertyLines Include="// &lt;auto-generated &gt;" />
48+
<_BuildPropertyLines Include="// &lt;Generated by the FSharp WriteCodeFragment class./&gt;" />
49+
<_BuildPropertyLines Include="// &lt;/auto-generated/&gt;" />
50+
<_BuildPropertyLines Include="//" />
51+
<_BuildPropertyLines Include="module internal FSharp.BuildProperties" />
52+
<_BuildPropertyLines Include="let fsProductVersion = &quot;$(FSPRODUCTVERSION)&quot;" />
53+
<_BuildPropertyLines Include="let fsLanguageVersion = &quot;$(FSLANGUAGEVERSION)&quot;" />
54+
</ItemGroup>
55+
56+
<MakeDir
57+
Directories="$(IntermediateOutputPath)"
58+
Condition="!Exists('$(IntermediateOutputPath)')" />
59+
<WriteLinesToFile File="$(IntermediateOutputPath)buildproperties.fs" Lines="@(_BuildPropertyLines)" Overwrite="true" WriteOnlyWhenDifferent="true" />
60+
61+
<!-- Make sure it will get cleaned -->
62+
<ItemGroup>
63+
<FileWrites Include="$(IntermediateOutputPath)buildproperties.fs" />
64+
<CompileBefore Include="$(IntermediateOutputPath)buildproperties.fs" />
65+
</ItemGroup>
66+
</Target>
67+
68+
<Target Name="BeforeResGen"
69+
Inputs="@(EmbeddedResource->'$(IntermediateOutputPath)%(Filename)%(Extension)')"
70+
Outputs="@(EmbeddedResource->'$(IntermediateOutputPath)resources\%(Filename)%(Extension)')"
71+
DependsOnTargets="CopyVsixResources"
72+
Condition="'$(Configuration)' != 'Proto' and '$(Language)'=='F#' and '$(DisableCompilerRedirection)' != 'true' ">
73+
74+
<SubstituteText EmbeddedResources="@(EmbeddedResource)">
75+
<Output TaskParameter="CopiedFiles" ItemName="CopiedFiles" />
76+
</SubstituteText>
77+
78+
<ItemGroup>
79+
<EmbeddedResource Remove="@(EmbeddedResource)"/>
80+
<EmbeddedResource Include="@(CopiedFiles)"/>
81+
</ItemGroup>
82+
83+
<MakeDir Directories="$(IntermediateOutputPath)" Condition="!Exists('$(IntermediateOutputPath)')" />
84+
<MakeDir Directories="$(IntermediateOutputPath)resources\" Condition="!Exists('$(IntermediateOutputPath)resources\')" />
85+
</Target>
86+
87+
<Target Name="CopyVsixResources">
88+
<Copy SourceFiles="@(CopyVsixResources)" DestinationFolder="$(IntermediateOutputPath)\resources\Resources" />
89+
</Target>
90+
91+
</Project>

fcs/build.fsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ Target.create "Build" (fun _ ->
6666
runDotnet __SOURCE_DIRECTORY__ "build" "../src/buildtools/buildtools.proj -v n -c Proto"
6767
let fslexPath = __SOURCE_DIRECTORY__ + "/../artifacts/bin/fslex/Proto/netcoreapp2.1/fslex.dll"
6868
let fsyaccPath = __SOURCE_DIRECTORY__ + "/../artifacts/bin/fsyacc/Proto/netcoreapp2.1/fsyacc.dll"
69-
runDotnet __SOURCE_DIRECTORY__ "build" (sprintf "FSharp.Compiler.Service.sln -v n -c Release /p:FsLexPath=%s /p:FsYaccPath=%s" fslexPath fsyaccPath)
69+
runDotnet __SOURCE_DIRECTORY__ "build" (sprintf "FSharp.Compiler.Service.sln -nodereuse:false -v n -c Release /p:DisableCompilerRedirection=true /p:FsLexPath=%s /p:FsYaccPath=%s" fslexPath fsyaccPath)
7070
)
7171

7272
Target.create "Test" (fun _ ->
7373
// This project file is used for the netcoreapp2.0 tests to work out reference sets
74-
runDotnet __SOURCE_DIRECTORY__ "build" "../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj -v n /restore /p:DisableCompilerRedirection=true"
74+
runDotnet __SOURCE_DIRECTORY__ "build" "../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj -nodereuse:false -v n /restore /p:DisableCompilerRedirection=true"
7575

7676
// Now run the tests
7777
let logFilePath = Path.Combine(__SOURCE_DIRECTORY__, "..", "artifacts", "TestResults", "Release", "FSharp.Compiler.Service.Test.xml")
78-
runDotnet __SOURCE_DIRECTORY__ "test" (sprintf "FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj --no-restore --no-build -v n -c Release --test-adapter-path . --logger \"nunit;LogFilePath=%s\"" logFilePath)
78+
runDotnet __SOURCE_DIRECTORY__ "test" (sprintf "FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj --no-restore --no-build -nodereuse:false -v n -c Release --test-adapter-path . --logger \"nunit;LogFilePath=%s\"" logFilePath)
7979
)
8080

8181
Target.create "NuGet" (fun _ ->

src/fsharp/FSharp.Build/FSharp.Build.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<Compile Include="FSharpEmbedResXSource.fs" />
2828
<Compile Include="WriteCodeFragment.fs" />
2929
<Compile Include="CreateFSharpManifestResourceName.fs" />
30+
<Compile Include="SubstituteText.fs" />
3031
<None Include="Microsoft.FSharp.Targets" CopyToOutputDirectory="PreserveNewest" />
3132
<None Include="Microsoft.Portable.FSharp.Targets" CopyToOutputDirectory="PreserveNewest" />
3233
<None Include="Microsoft.FSharp.NetSdk.targets" CopyToOutputDirectory="PreserveNewest" />

src/fsharp/FSharp.Build/Microsoft.FSharp.Targets

Lines changed: 1 addition & 0 deletions
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>
Lines changed: 92 additions & 0 deletions
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

vsintegration/Vsix/RegisterFsharpPackage.pkgdef

Lines changed: 1 addition & 1 deletion
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

vsintegration/Vsix/VisualFSharpFull/VisualFSharpFull.csproj

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@
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+
<IncludeInVSix>true</IncludeInVSix>
25+
</NoneSubstituteText>
26+
2227
<Content Include="$(FSharpSourcesRoot)\..\License.txt">
2328
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2429
<Link>License.txt</Link>
2530
<IncludeInVSIX>true</IncludeInVSIX>
2631
</Content>
32+
2733
<Content Include="$(NuGetPackageRoot)\Microsoft.VisualFSharp.Type.Providers.Redist\$(MicrosoftVisualFSharpTypeProvidersRedistVersion)\content\$(FSharpDataTypeProvidersVersion)\FSharp.Data.TypeProviders.dll">
2834
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2935
<Link>FSharp.Data.TypeProviders.dll</Link>

vsintegration/src/FSharp.ProjectSystem.FSharp/ProjectSystem.fsproj

Lines changed: 9 additions & 0 deletions
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" />

vsintegration/src/FSharp.ProjectSystem.FSharp/VSPackage.resx

Lines changed: 3 additions & 3 deletions
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>

vsintegration/src/FSharp.ProjectSystem.FSharp/xlf/VSPackage.cs.xlf

Lines changed: 6 additions & 6 deletions
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">

vsintegration/src/FSharp.ProjectSystem.FSharp/xlf/VSPackage.de.xlf

Lines changed: 6 additions & 6 deletions
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">

0 commit comments

Comments
 (0)