Skip to content

Commit 59dae45

Browse files
authored
Fix early/unconditional execution of PackageFSharpDesignTimeTools target (#18929)
1 parent 1ff7cb1 commit 59dae45

File tree

15 files changed

+400
-3
lines changed

15 files changed

+400
-3
lines changed

azure-pipelines-PR.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,15 @@ stages:
732732
steps:
733733
- checkout: self
734734
clean: true
735+
# We first download a publicly available .NET SDK. That one has support for `path` in global.json. dotnet.cmd script can then download a version which is not yet shipped, but matches global.json.
736+
- task: UseDotNet@2
737+
displayName: install SDK
738+
inputs:
739+
packageType: sdk
740+
version: '10.x'
741+
includePreviewVersions: true
742+
workingDirectory: $(Build.SourcesDirectory)
743+
installationPath: $(Build.SourcesDirectory)/.dotnet
735744
- script: .\Build.cmd -c Release -pack
736745
env:
737746
NativeToolsOnMachine: true

docs/release-notes/.FSharp.Compiler.Service/10.0.100.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* Tests: set test source for range debug printing ([PR #18879](https://github.com/dotnet/fsharp/pull/18879))
3535
* Checker: fix declaring type for abbreviated types extensions ([PR #18909](https://github.com/dotnet/fsharp/pull/18909))
3636
* Caches: type subsumption cache key perf regression ([Issue #18925](https://github.com/dotnet/fsharp/issues/18925) [PR #18926](https://github.com/dotnet/fsharp/pull/18926))
37+
* Fix early/unconditional execution of PackageFSharpDesignTimeTools target. ([Issue #18924](https://github.com/dotnet/fsharp/issues/18924), [Issue #12320](https://github.com/dotnet/fsharp/issues/12320))
3738
* Ensure that line directives are applied to source identifiers (issue [#18908](https://github.com/dotnet/fsharp/issues/18908), PR [#18918](https://github.com/dotnet/fsharp/pull/18918))
3839
* Fix expected and actual types in ErrorFromAddingTypeEquation message and extended diagnostic data. ([PR #18915](https://github.com/dotnet/fsharp/pull/18915))
3940
* Editor: Fix Record fields completion in update record with partial field name. ([PR #18946](https://github.com/dotnet/fsharp/pull/18946))

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,23 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
4949
<PackProjectInputFile>$(MSBuildProjectFullPath)</PackProjectInputFile>
5050
</PropertyGroup>
5151

52-
<PropertyGroup>
52+
<!-- Gate inclusion of PackageFSharpDesignTimeTools target when design-time provider is present -->
53+
<PropertyGroup Condition=" '$(IsFSharpDesignTimeProvider)' == 'true' ">
5354
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackageFSharpDesignTimeTools</TargetsForTfmSpecificContentInPackage>
5455
</PropertyGroup>
5556

57+
<!-- Check for design-time provider references and add target if needed -->
58+
<!-- This target attempts to update TargetsForTfmSpecificContentInPackage based on reference metadata -->
59+
<Target Name="_CheckForDesignTimeProviderReferences" BeforeTargets="GenerateNuspec" Condition=" '$(IsFSharpDesignTimeProvider)' != 'true' ">
60+
<ItemGroup>
61+
<_FSharpDesignTimeProviderProject Include="@(ProjectReference)" Condition="'%(ProjectReference.IsFSharpDesignTimeProvider)' == 'true'" />
62+
<_FSharpDesignTimeProviderPackage Include="@(PackageReference)" Condition="'%(PackageReference.IsFSharpDesignTimeProvider)' == 'true'" />
63+
</ItemGroup>
64+
<PropertyGroup Condition=" '@(_FSharpDesignTimeProviderProject)' != '' or '@(_FSharpDesignTimeProviderPackage)' != '' ">
65+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackageFSharpDesignTimeTools</TargetsForTfmSpecificContentInPackage>
66+
</PropertyGroup>
67+
</Target>
68+
5669
<PropertyGroup Condition=" '$(DisableImplicitLibraryPacksFolder)' != 'true' ">
5770
<RestoreAdditionalProjectSources Condition="Exists('$(_FSharpCoreLibraryPacksFolder)')">$(RestoreAdditionalProjectSources);$(_FSharpCoreLibraryPacksFolder)</RestoreAdditionalProjectSources>
5871
</PropertyGroup>
@@ -65,7 +78,8 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
6578
</ItemGroup>
6679
</Target>
6780

68-
<Target Name="PackageFSharpDesignTimeTools" DependsOnTargets="_GetFrameworkAssemblyReferences">
81+
<Target Name="PackageFSharpDesignTimeTools" AfterTargets="ResolveReferences">
82+
<CallTarget Targets="_GetFrameworkAssemblyReferences" Condition="'@(ReferencePath)' == ''" />
6983
<PropertyGroup>
7084
<FSharpDesignTimeProtocol Condition = " '$(FSharpDesignTimeProtocol)' == '' ">fsharp41</FSharpDesignTimeProtocol>
7185
<FSharpToolsDirectory Condition = " '$(FSharpToolsDirectory)' == '' ">tools</FSharpToolsDirectory>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net10.0</TargetFramework>
6+
<FSharpCoreImplicitPackageVersion>$(FSharpCoreShippedPackageVersionValue)</FSharpCoreImplicitPackageVersion>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<Compile Include="Library.fs" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\Provider\Provider.fsproj">
15+
<IsFSharpDesignTimeProvider>true</IsFSharpDesignTimeProvider>
16+
<PrivateAssets>all</PrivateAssets>
17+
</ProjectReference>
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace Host
2+
3+
module Library =
4+
let hostFunc name = sprintf "Host says hello %s" name
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace PlainLib
2+
3+
module Library =
4+
let hello name = sprintf "Hello %s" name
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net10.0</TargetFramework>
6+
<FSharpCoreImplicitPackageVersion>$(FSharpCoreShippedPackageVersionValue)</FSharpCoreImplicitPackageVersion>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<Compile Include="Library.fs" />
11+
</ItemGroup>
12+
13+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace Provider
2+
3+
module Library =
4+
let providerFunc name = sprintf "Provider says hello %s" name
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net10.0</TargetFramework>
6+
<FSharpCoreImplicitPackageVersion>$(FSharpCoreShippedPackageVersionValue)</FSharpCoreImplicitPackageVersion>
7+
<IsFSharpDesignTimeProvider>true</IsFSharpDesignTimeProvider>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<Compile Include="Library.fs" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace RedirectLib
2+
3+
module Library =
4+
let redirectFunc name = sprintf "RedirectLib says hello %s" name

0 commit comments

Comments
 (0)