Skip to content

Commit 858642d

Browse files
authored
Preview package (#6761)
* Allow targetting of preview FSharp.Core. Parameterize dsharp.core versions * Parameterise app.config generation * parameterize banner text * Do app.config right * fcs * fcs tests * add discriminator * Update FSharp.Compiler.Service.ProjectCrackerTool.fsproj * remove dead file
1 parent 7383ead commit 858642d

File tree

60 files changed

+306
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+306
-93
lines changed

FSharpBuild.Directory.Build.targets

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,59 @@
55
<Import Project="eng\targets\NGenBinaries.targets" />
66
<Import Project="FSharp.Profiles.props" />
77

8-
<PropertyGroup>
9-
<CompileDependsOn>$(CompileDependsOn);CopyAndSubstituteTextFiles</CompileDependsOn>
10-
</PropertyGroup>
11-
128
<Target Name="CopyAndSubstituteTextFiles"
139
Inputs="@(CopyAndSubstituteText)"
14-
Outputs="@(CopyAndSubstituteText->'$(OutDir)%(TargetFilename)')">
10+
Outputs="@(CopyAndSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')"
11+
BeforeTargets="BeforeBuild">
12+
1513
<PropertyGroup>
14+
<__TargetFilePath>@(CopyAndSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')</__TargetFilePath>
15+
<__TargetFileName>@(CopyAndSubstituteText->'%(Filename)%(Extension)')</__TargetFileName>
16+
1617
<_ReplacementText>$([System.IO.File]::ReadAllText('%(CopyAndSubstituteText.FullPath)'))</_ReplacementText>
1718
<_ReplacementText Condition="'%(CopyAndSubstituteText.Pattern1)' != ''">$(_ReplacementText.Replace('%(CopyAndSubstituteText.Pattern1)', '%(CopyAndSubstituteText.Replacement1)'))</_ReplacementText>
1819
<_ReplacementText Condition="'%(CopyAndSubstituteText.Pattern2)' != ''">$(_ReplacementText.Replace('%(CopyAndSubstituteText.Pattern2)', '%(CopyAndSubstituteText.Replacement2)'))</_ReplacementText>
1920
</PropertyGroup>
20-
<WriteLinesToFile File="$(OutDir)%(CopyAndSubstituteText.TargetFilename)" Lines="$(_ReplacementText)" Overwrite="true" />
21+
22+
<MakeDir
23+
Directories="$(IntermediateOutputPath)"
24+
Condition="!Exists('$(IntermediateOutputPath)')" />
25+
<WriteLinesToFile File="$(__TargetFilePath)" Lines="$(_ReplacementText)" Overwrite="true" />
26+
27+
<!-- Make sure it will get cleaned -->
28+
<ItemGroup >
29+
<None Include="$(__TargetFilePath)" Condition="'$(__TargetFileName)' == 'App.config'" CopyToOutputDirectory="Never" />
30+
<None Include="$(__TargetFilePath)" Condition="'$(__TargetFileName)' != 'App.config'" CopyToOutputDirectory="PreserveNewest" />
31+
<FileWrites Include="$(__TargetFilePath)" Condition="'$(__TargetFileName)' != 'App.config'" />
32+
</ItemGroup>
33+
</Target>
34+
35+
<Target Name="_GenerateBuildPropertiesFile"
36+
Outputs="$(IntermediateOutputPath)buildproperties.fs"
37+
BeforeTargets="BeforeBuild"
38+
Condition="'$(Language)'=='F#'">
39+
40+
<ItemGroup>
41+
<_BuildPropertyLines Remove="@(_BuildPropertyLines)" />
42+
<_BuildPropertyLines Include="// &lt;auto-generated &gt;" />
43+
<_BuildPropertyLines Include="// &lt;Generated by the FSharp WriteCodeFragment class./&gt;" />
44+
<_BuildPropertyLines Include="// &lt;/auto-generated/&gt;" />
45+
<_BuildPropertyLines Include="//" />
46+
<_BuildPropertyLines Include="module internal FSharp.BuildProperties" />
47+
<_BuildPropertyLines Include="let fsProductVersion = &quot;$(FSPRODUCTVERSION)&quot;" />
48+
<_BuildPropertyLines Include="let fsLanguageVersion = &quot;$(FSLANGUAGEVERSION)&quot;" />
49+
</ItemGroup>
50+
51+
<MakeDir
52+
Directories="$(IntermediateOutputPath)"
53+
Condition="!Exists('$(IntermediateOutputPath)')" />
54+
<WriteLinesToFile File="$(IntermediateOutputPath)buildproperties.fs" Lines="@(_BuildPropertyLines)" Overwrite="true" />
55+
2156
<!-- Make sure it will get cleaned -->
22-
<CreateItem Include="$(OutDir)%(CopyAndSubstituteText.TargetFilename)">
23-
<Output TaskParameter="Include" ItemName="FileWrites" />
24-
</CreateItem>
57+
<ItemGroup>
58+
<FileWrites Include="$(IntermediateOutputPath)buildproperties.fs" />
59+
<CompileBefore Include="$(IntermediateOutputPath)buildproperties.fs" />
60+
</ItemGroup>
2561
</Target>
2662

2763
</Project>

eng/Versions.props

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@
1212
<!-- Version number computation -->
1313
<PropertyGroup>
1414
<PreReleaseVersionLabel>beta</PreReleaseVersionLabel>
15-
<FSCoreMajorVersion>4.6</FSCoreMajorVersion>
15+
<FSLanguageVersion>4.6</FSLanguageVersion>
16+
<FSCoreMajorVersion>$(FSLanguageVersion)</FSCoreMajorVersion>
1617
<FSCorePackageVersion>$(FSCoreMajorVersion).3</FSCorePackageVersion>
1718
<FSCoreVersionPrefix>$(FSCoreMajorVersion).0</FSCoreVersionPrefix>
1819
<FSCoreVersion>$(FSCoreVersionPrefix).0</FSCoreVersion>
20+
<!-- The current published nuget package -->
21+
<FSharpCoreShippedPackageVersion>4.6.2</FSharpCoreShippedPackageVersion>
22+
<!-- The pattern for specifying the preview package -->
23+
<FSharpCorePreviewPackageVersion>$(FSCorePackageVersion)-$(PreReleaseVersionLabel).*</FSharpCorePreviewPackageVersion>
1924
</PropertyGroup>
2025
<PropertyGroup>
2126
<FSPackageMajorVersion>10.4</FSPackageMajorVersion>
@@ -184,4 +189,4 @@
184189
<RoslynToolsSignToolVersion>1.0.0-beta2-dev3</RoslynToolsSignToolVersion>
185190
<StrawberryPerl64Version>5.22.2.1</StrawberryPerl64Version>
186191
</PropertyGroup>
187-
</Project>
192+
</Project>

fcs/Directory.Build.targets

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,58 @@
11
<Project>
2-
<!-- empty to prevent directory crawling -->
2+
3+
<Target Name="CopyAndSubstituteTextFiles"
4+
Inputs="@(CopyAndSubstituteText)"
5+
Outputs="@(CopyAndSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')"
6+
BeforeTargets="BeforeBuild">
7+
8+
<PropertyGroup>
9+
<__TargetFilePath>@(CopyAndSubstituteText->'$(IntermediateOutputPath)%(Filename)%(Extension)')</__TargetFilePath>
10+
<__TargetFileName>@(CopyAndSubstituteText->'%(Filename)%(Extension)')</__TargetFileName>
11+
12+
<_ReplacementText>$([System.IO.File]::ReadAllText('%(CopyAndSubstituteText.FullPath)'))</_ReplacementText>
13+
<_ReplacementText Condition="'%(CopyAndSubstituteText.Pattern1)' != ''">$(_ReplacementText.Replace('%(CopyAndSubstituteText.Pattern1)', '%(CopyAndSubstituteText.Replacement1)'))</_ReplacementText>
14+
<_ReplacementText Condition="'%(CopyAndSubstituteText.Pattern2)' != ''">$(_ReplacementText.Replace('%(CopyAndSubstituteText.Pattern2)', '%(CopyAndSubstituteText.Replacement2)'))</_ReplacementText>
15+
</PropertyGroup>
16+
17+
<MakeDir
18+
Directories="$(IntermediateOutputPath)"
19+
Condition="!Exists('$(IntermediateOutputPath)')" />
20+
<WriteLinesToFile File="$(__TargetFilePath)" Lines="$(_ReplacementText)" Overwrite="true" />
21+
22+
<!-- Make sure it will get cleaned -->
23+
<ItemGroup >
24+
<None Include="$(__TargetFilePath)" Condition="'$(__TargetFileName)' == 'App.config'" CopyToOutputDirectory="Never" />
25+
<None Include="$(__TargetFilePath)" Condition="'$(__TargetFileName)' != 'App.config'" CopyToOutputDirectory="PreserveNewest" />
26+
<FileWrites Include="$(__TargetFilePath)" Condition="'$(__TargetFileName)' != 'App.config'" />
27+
</ItemGroup>
28+
</Target>
29+
30+
<Target Name="_GenerateBuildPropertiesFile"
31+
Outputs="$(IntermediateOutputPath)$(ProjectName)\buildproperties.fs"
32+
BeforeTargets="BeforeBuild"
33+
Condition="'$(Language)'=='F#'">
34+
35+
<ItemGroup>
36+
<_BuildPropertyLines Remove="@(_BuildPropertyLines)" />
37+
<_BuildPropertyLines Include="// &lt;auto-generated &gt;" />
38+
<_BuildPropertyLines Include="// &lt;Generated by the FSharp WriteCodeFragment class./&gt;" />
39+
<_BuildPropertyLines Include="// &lt;/auto-generated/&gt;" />
40+
<_BuildPropertyLines Include="//" />
41+
<_BuildPropertyLines Include="module internal FSharp.BuildProperties" />
42+
<_BuildPropertyLines Include="let fsProductVersion = &quot;$(FSPRODUCTVERSION)&quot;" />
43+
<_BuildPropertyLines Include="let fsLanguageVersion = &quot;$(FSLANGUAGEVERSION)&quot;" />
44+
</ItemGroup>
45+
46+
<MakeDir
47+
Directories="$(IntermediateOutputPath)$(ProjectName)"
48+
Condition="!Exists('$(IntermediateOutputPath)$(ProjectName)')" />
49+
<WriteLinesToFile File="$(IntermediateOutputPath)$(ProjectName)\buildproperties.fs" Lines="@(_BuildPropertyLines)" Overwrite="true" />
50+
51+
<!-- Make sure it will get cleaned -->
52+
<ItemGroup>
53+
<FileWrites Include="$(IntermediateOutputPath)$(ProjectName)\buildproperties.fs" />
54+
<CompileBefore Include="$(IntermediateOutputPath)$(ProjectName)\buildproperties.fs" />
55+
</ItemGroup>
56+
</Target>
57+
358
</Project>

fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@
7373
<Compile Include="$(FSharpSourcesRoot)\..\tests\service\Program.fs" Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
7474
<Link>Program.fs</Link>
7575
</Compile>
76-
<None Include="App.config" />
76+
<CopyAndSubstituteText Include="App.config">
77+
<Pattern1>{{FSCoreVersion}}</Pattern1>
78+
<Replacement1>$(FSCoreVersion)</Replacement1>
79+
</CopyAndSubstituteText>
7780
</ItemGroup>
7881
<ItemGroup>
7982
<PackageReference Include="FSharp.Core" Version="$(FcsFSharpCorePkgVersion)" />

fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<DefineConstants>$(DefineConstants);COMPILER</DefineConstants>
99
<DefineConstants>$(DefineConstants);ENABLE_MONO_SUPPORT</DefineConstants>
1010
<DefineConstants>$(DefineConstants);NO_STRONG_NAMES</DefineConstants>
11+
<DefineConstants>$(DefineConstants);LOCALIZATION_FSCOMP</DefineConstants>
1112
<FsLexOutputFolder Condition="'$(TargetFramework)' != ''">$(TargetFramework)\</FsLexOutputFolder>
1213
<FsYaccOutputFolder Condition="'$(TargetFramework)' != ''">$(TargetFramework)\</FsYaccOutputFolder>
1314
<OtherFlags>$(OtherFlags) /warnon:1182</OtherFlags>

src/fsharp/FSComp.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,3 +1462,4 @@ notAFunctionButMaybeDeclaration,"This value is not a function and cannot be appl
14621462
3300,chkInvalidFunctionParameterType,"The parameter '%s' has an invalid type '%s'. This is not permitted by the rules of Common IL."
14631463
3301,chkInvalidFunctionReturnType,"The function or method has an invalid return type '%s'. This is not permitted by the rules of Common IL."
14641464
useSdkRefs,"Use reference assemblies for .NET framework references when available (Enabled by default)."
1465+
fSharpBannerVersion,"%s for F# %s"
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# FSharp.Build resource strings
2-
toolpathUnknown,"ToolPath is unknown; specify the path to the tool."
2+
toolpathUnknown,"ToolPath is unknown; specify the path to the tool."
3+
fSharpBannerVersion,"%s for F# %s"

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<AllowCrossTargeting>true</AllowCrossTargeting>
1212
<OtherFlags>$(OtherFlags) --maxerrors:20 --extraoptimizationloops:1</OtherFlags>
1313
<NGenBinary>true</NGenBinary>
14+
<DefineConstants>$(DefineConstants);LOCALIZATION_FSBUILD</DefineConstants>
1415
</PropertyGroup>
1516

1617
<ItemGroup>
@@ -27,8 +28,14 @@
2728
<Compile Include="CreateFSharpManifestResourceName.fs" />
2829
<None Include="Microsoft.FSharp.Targets" CopyToOutputDirectory="PreserveNewest" />
2930
<None Include="Microsoft.Portable.FSharp.Targets" CopyToOutputDirectory="PreserveNewest" />
30-
<None Include="Microsoft.FSharp.NetSdk.props" CopyToOutputDirectory="PreserveNewest" />
3131
<None Include="Microsoft.FSharp.NetSdk.targets" CopyToOutputDirectory="PreserveNewest" />
32+
<CopyAndSubstituteText Include="Microsoft.FSharp.NetSdk.props">
33+
<TargetFileName>Microsoft.FSharp.NetSdk.props</TargetFileName>
34+
<Pattern1>{{FSharpCoreShippedPackageVersion}}</Pattern1>
35+
<Replacement1>$(FSharpCoreShippedPackageVersion)</Replacement1>
36+
<Pattern2>{{FSharpCorePreviewPackageVersion}}</Pattern2>
37+
<Replacement2>$(FSharpCorePreviewPackageVersion)</Replacement2>
38+
</CopyAndSubstituteText>
3239
<None Include="Microsoft.FSharp.Overrides.NetSdk.targets" CopyToOutputDirectory="PreserveNewest" />
3340
</ItemGroup>
3441

src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
7474

7575
<PropertyGroup>
7676
<DefaultValueTuplePackageVersion>4.4.0</DefaultValueTuplePackageVersion>
77-
<DefaultFSharpCorePackageVersion>4.6.2</DefaultFSharpCorePackageVersion>
77+
<DefaultFSharpCorePackageVersion>{{FSharpCoreShippedPackageVersion}}</DefaultFSharpCorePackageVersion>
78+
<DefaultFSharpCorePreviewPackageVersion>{{FSharpCorePreviewPackageVersion}}</DefaultFSharpCorePreviewPackageVersion>
7879
<ValueTupleImplicitPackageVersion>$(DefaultValueTuplePackageVersion)</ValueTupleImplicitPackageVersion>
7980
<FSharpCoreImplicitPackageVersion>$(DefaultFSharpCorePackageVersion)</FSharpCoreImplicitPackageVersion>
8081
</PropertyGroup>

src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.targets

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
5252
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackageFSharpDesignTimeTools</TargetsForTfmSpecificContentInPackage>
5353
</PropertyGroup>
5454

55+
<!-- When the developer specifies UseFSharpPreview=true then resolve the highest preview package from the F# myget feed -->
56+
<PropertyGroup Condition="'$(UseFSharpPreview)' == 'true'">
57+
<FSharpCoreImplicitPackageVersion>$(DefaultFSharpCorePreviewPackageVersion)</FSharpCoreImplicitPackageVersion>
58+
<RestoreSources>$(RestoreSources); https://dotnet.myget.org/F/fsharp/api/v3/index.json</RestoreSources>
59+
</PropertyGroup>
60+
5561
<Target Name="PackageFSharpDesignTimeTools" DependsOnTargets="_GetFrameworkAssemblyReferences">
5662
<PropertyGroup>
5763
<FSharpDesignTimeProtocol Condition = " '$(FSharpDesignTimeProtocol)' == '' ">fsharp41</FSharpDesignTimeProtocol>

0 commit comments

Comments
 (0)