Skip to content

Commit 01c621c

Browse files
committed
Update Microsoft.FSharp.targets to match what is shipped in VS. This had gotten stale over the past couple of releases. (changeset 1275028)
1 parent 54942ba commit 01c621c

File tree

1 file changed

+67
-19
lines changed

1 file changed

+67
-19
lines changed

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

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,24 @@ this file.
2020
<UsingTask TaskName="Fsc" AssemblyFile="FSharp.Build{BuildSuffix}.dll"/>
2121
<UsingTask TaskName="CreateFSharpManifestResourceName" AssemblyFile="FSharp.Build{BuildSuffix}.dll"/>
2222

23+
<PropertyGroup>
24+
<ImportByWildcardBeforeMicrosoftFSharpTargets Condition="'$(ImportByWildcardBeforeMicrosoftFSharpTargets)' == ''">true</ImportByWildcardBeforeMicrosoftFSharpTargets>
25+
<ImportByWildcardAfterMicrosoftFSharpTargets Condition="'$(ImportByWildcardAfterMicrosoftFSharpTargets)' == ''">true</ImportByWildcardAfterMicrosoftFSharpTargets>
26+
</PropertyGroup>
27+
28+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore\*" Condition="'$(ImportByWildcardBeforeMicrosoftFSharpTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore')"/>
2329

2430
<PropertyGroup>
25-
<!-- FSharpTargetsDir is the directory where the targets file lives -->
26-
<FSharpTargetsDir Condition="'$(FSharpTargetsDir)'==''">{FSharpTargetsDir}</FSharpTargetsDir>
27-
<!-- FSharpTargetsFullPath is the full path (dir + filename) of the targets file -->
28-
<FSharpTargetsFullPath Condition="'$(FSharpTargetsDir)'!=''">$(FSharpTargetsDir)\Microsoft.FSharp{BuildSuffix}.targets</FSharpTargetsFullPath>
29-
<MSBuildAllProjects>$(MSBuildAllProjects);$(FSharpTargetsFullPath)</MSBuildAllProjects>
31+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
3032
<DefaultLanguageSourceExtension>.fs</DefaultLanguageSourceExtension>
3133
<Language>F#</Language>
34+
<TargetRuntime>Managed</TargetRuntime>
3235
<Tailcalls Condition="'$(Tailcalls)'==''">$(Optimize)</Tailcalls>
3336
<FrameworkRegistryBase Condition="'$(TargetFrameworkIdentifier)'=='Silverlight'">Software\Microsoft\Microsoft SDKs\$(TargetFrameworkIdentifier)</FrameworkRegistryBase>
3437
<!-- Visual studio requires a non-empty RootNamespace value for "Add New Item" to work. -->
3538
<RootNamespace Condition="'$(RootNamespace)'==''">RootNamespace</RootNamespace>
39+
<Actual32Bit Condition="'$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0'">false</Actual32Bit>
40+
<Actual32Bit Condition="!('$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0')">$(Prefer32Bit)</Actual32Bit>
3641
</PropertyGroup>
3742

3843
<!--
@@ -70,20 +75,20 @@ this file.
7075

7176
<!-- Create manifest names for culture and non-culture Resx files, and for non-culture Non-Resx resources -->
7277
<CreateFSharpManifestResourceName
73-
ResourceFiles="@(EmbeddedResource)"
74-
RootNamespace="$(RootNamespace)"
75-
Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and ('%(EmbeddedResource.WithCulture)' == 'false' or '%(EmbeddedResource.Type)' == 'Resx')">
78+
ResourceFiles="@(EmbeddedResource)"
79+
RootNamespace="$(RootNamespace)"
80+
Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and ('%(EmbeddedResource.WithCulture)' == 'false' or '%(EmbeddedResource.Type)' == 'Resx')">
7681

7782
<Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" />
7883

7984
</CreateFSharpManifestResourceName>
8085

8186
<!-- Create manifest names for all culture non-resx resources -->
8287
<CreateFSharpManifestResourceName
83-
ResourceFiles="@(EmbeddedResource)"
84-
RootNamespace="$(RootNamespace)"
85-
PrependCultureAsDirectory="false"
86-
Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx'">
88+
ResourceFiles="@(EmbeddedResource)"
89+
RootNamespace="$(RootNamespace)"
90+
PrependCultureAsDirectory="false"
91+
Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx'">
8792

8893
<Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" />
8994

@@ -132,15 +137,14 @@ this file.
132137
@(_DebugSymbolsIntermediatePath);
133138
$(NonExistentFile);
134139
@(CustomAdditionalCompileOutputs)"
140+
Returns=""
135141
DependsOnTargets="$(CoreCompileDependsOn)"
136142
>
137143

138-
<!-- See bug 6053
139-
<Error
140-
Condition="'$(SilverlightVersion)' != '' and !(Exists('$(ProgramFiles)\Microsoft F#\Silverlight\Libraries\Client\$(SilverlightVersion)\FSharp.Core.dll'))"
141-
Text="F# runtime for Silverlight version $(SilverlightVersion) is not installed. Please go to http://go.microsoft.com/fwlink/?LinkId=177463 to download and install matching F# runtime"
142-
/>
143-
-->
144+
<Error
145+
Condition="'$(SilverlightVersion)' != '' and '$(SilverlightVersion)' != 'v5.0'"
146+
Text="In this version of Visual Studio, F# for Silverlight can only target Silverlight v5.0. Use a prior version of Visual Studio to target previous versions of Silverlight with F#."
147+
/>
144148

145149
<Warning
146150
Condition="'$(Win32ResourceFile)' != '' "
@@ -165,6 +169,7 @@ this file.
165169
OutputAssembly="@(IntermediateAssembly)"
166170
PdbFile="$(PdbFile)"
167171
Platform="$(PlatformTarget)"
172+
Prefer32Bit="$(Actual32Bit)"
168173
References="@(ReferencePath)"
169174
ReferencePath="$(ReferencePath)"
170175
Resources="@(_CoreCompileResourceInputs);@(CompiledLicenseFile);@(AdditionalEmbeddedResource)"
@@ -182,14 +187,57 @@ this file.
182187
WarningsAsErrors="$(WarningsAsErrors)"
183188
Win32ManifestFile="$(Win32Manifest)"
184189
Win32ResourceFile="$(Win32Resource)"
185-
/>
190+
SubsystemVersion="$(SubsystemVersion)"
191+
HighEntropyVA="$(HighEntropyVA)"
192+
TargetProfile="$(TargetProfile)"
193+
SqmSessionGuid="$(SqmSessionGuid)"
194+
/>
186195

187196
<ItemGroup>
188197
<_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)" />
189198
</ItemGroup>
190199

191200
</Target>
192201

202+
193203
<Import Project="$(MSBuildBinPath)\Microsoft.Common.targets"/>
194204

205+
<!--
206+
============================================================
207+
GenerateTargetFrameworkMonikerAttribute
208+
209+
Emit the target framework moniker attribute as a code fragment into a temporary source file for the compiler.
210+
211+
============================================================
212+
-->
213+
214+
<Target Name="GenerateTargetFrameworkMonikerAttribute" BeforeTargets="BeforeCompile" DependsOnTargets="PrepareForBuild;GetReferenceAssemblyPaths" Inputs="$(MSBuildThisFileFullPath)" Outputs="$(TargetFrameworkMonikerAssemblyAttributesPath)" Condition="'$(GenerateTargetFrameworkAttribute)' == 'true'">
215+
216+
<PropertyGroup>
217+
<!-- This attribute is only available in mscorlib v4 and later -->
218+
<AdditionalSourcesText Condition="'$(TargetFrameworkMoniker)' != '' and '$(TargetingClr2Framework)' != 'true'">
219+
$(AdditionalSourcesText)
220+
namespace Microsoft.BuildSettings
221+
[&lt;System.Runtime.Versioning.TargetFrameworkAttribute(&quot;$(TargetFrameworkMoniker)&quot;, FrameworkDisplayName=&quot;$(TargetFrameworkMonikerDisplayName)&quot;)&gt;]
222+
do ()
223+
</AdditionalSourcesText>
224+
</PropertyGroup>
225+
226+
<!-- This is a file shared between projects so we have to take care to handle simultaneous writes (by ContinueOnError)
227+
and a race between clean from one project and build from another (by not adding to FilesWritten so it doesn't clean) -->
228+
<WriteLinesToFile
229+
File="$(TargetFrameworkMonikerAssemblyAttributesPath)"
230+
Lines="$(AdditionalSourcesText)"
231+
Condition="'$(AdditionalSourcesText)' != ''"
232+
ContinueOnError="true"
233+
Overwrite="true"/>
234+
235+
<ItemGroup>
236+
<CompileBefore Include="$(TargetFrameworkMonikerAssemblyAttributesPath)" Condition="'$(AdditionalSourcesText)' != ''"/>
237+
</ItemGroup>
238+
239+
</Target>
240+
241+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter\*" Condition="'$(ImportByWildcardAfterMicrosoftFSharpTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter')"/>
242+
195243
</Project>

0 commit comments

Comments
 (0)