File size: 30,586 Bytes
090629c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
<!-- Copyright (c) Microsoft Corporation.  All Rights Reserved.  See License.txt in the project root for license information. -->

<!--

***********************************************************************************************

Microsoft.FSharp.Targets



WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have

          created a backup copy.  Incorrect changes to this file will make it

          impossible to load or build your projects from the command-line or the IDE.



This file defines the steps in the standard build process specific for F# .NET projects.

For example, it contains the step that actually calls the F# compiler.  The remainder

of the build process is defined in Microsoft.Common.targets, which is imported by 

this file.

***********************************************************************************************

-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <PropertyGroup>
        <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
        <FSharpBuildAssemblyFile Condition=" '$(FSharpBuildAssemblyFile)' =='' ">$(MSBuildThisFileDirectory)FSharp.Build.dll</FSharpBuildAssemblyFile>
    </PropertyGroup>

    <UsingTask TaskName="Fsc" AssemblyFile="$(FSharpBuildAssemblyFile)" />
    <UsingTask TaskName="Fsi" AssemblyFile="$(FSharpBuildAssemblyFile)" />
    <UsingTask TaskName="FSharpEmbedResourceText" AssemblyFile="$(FSharpBuildAssemblyFile)" />
    <UsingTask TaskName="FSharpEmbedResXSource" AssemblyFile="$(FSharpBuildAssemblyFile)" />
    <UsingTask TaskName="CreateFSharpManifestResourceName" AssemblyFile="$(FSharpBuildAssemblyFile)" />
    <UsingTask TaskName="WriteCodeFragment" AssemblyFile="$(FSharpBuildAssemblyFile)" />
    <UsingTask TaskName="FSharpPlatformInformation" AssemblyFile="$(FSharpBuildAssemblyFile)" />
    <UsingTask TaskName="SubstituteText" AssemblyFile="$(FSharpBuildAssemblyFile)" />

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

    <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore\*" Condition="'$(ImportByWildcardBeforeMicrosoftFSharpTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore')"/>

    <PropertyGroup>
        <DefaultLanguageSourceExtension>.fs</DefaultLanguageSourceExtension>
        <Language>F#</Language>
        <TargetRuntime>Managed</TargetRuntime>
        <Tailcalls Condition="'$(Tailcalls)'==''">$(Optimize)</Tailcalls>
        <FrameworkRegistryBase Condition="'$(TargetFrameworkIdentifier)'=='Silverlight'">Software\Microsoft\Microsoft SDKs\$(TargetFrameworkIdentifier)</FrameworkRegistryBase>
        <!-- Visual studio requires a non-empty RootNamespace value for "Add New Item" to work. -->
        <RootNamespace Condition="'$(RootNamespace)'==''">RootNamespace</RootNamespace>
        <Actual32Bit Condition="'$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0'">false</Actual32Bit>
        <Actual32Bit Condition="!('$(TargetFrameworkVersion)'=='v2.0' or '$(TargetFrameworkVersion)'=='v3.0' or '$(TargetFrameworkVersion)'=='v3.5' or '$(TargetFrameworkVersion)'=='v4.0')">$(Prefer32Bit)</Actual32Bit>
    </PropertyGroup>

    <!--

      Project file properties that control compiler selection:

      ========================================================

      Suggest that the compiler used be the desktop framework version.  On computers without Visual Studio these properties is ignored.

      <FSharpPreferNetFrameworkTools>  boolean: true or false === default value true



      Suggest that the compiler used be the 64 Bit compiler.  On computers without Visual Studio this property is ignored.

      <FSharpPreferAnyCpuTools>      boolean: true or false === default value true

      <FSharpPrefer64BitTools>      boolean: true or false === default value true



      These are stupidly complex for performance reasons:

        Arm64 is faster than AnyCpu on an Arm64 machine



      On Windows Arm64 default to Arm64 build, otherwise default to AnyCpu.

    -->

    <PropertyGroup Condition="'$(FSharp_Shim_Present)' == 'true'">
        <FSharpPreferNetFrameworkTools Condition="'$(FSharpPreferNetFrameworkTools)' == ''">true</FSharpPreferNetFrameworkTools>
    </PropertyGroup>

    <PropertyGroup Condition="'$(FSharp_Shim_Present)' == 'true' and '$(FSharpPreferNetFrameworkTools)' == 'true'">


        <!-- Nothing set so use default, Arm, default to native arm, X64 default to AnyCpu -->
        <FSharpPreferAnyCpuTools Condition="'$(FSharpPreferAnyCpuTools)' == '' and '$(FSharpPrefer64BitTools)' == '' and '$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture)' == 'Arm64'">false</FSharpPreferAnyCpuTools>
        <FSharpPreferAnyCpuTools Condition="'$(FSharpPreferAnyCpuTools)' == '' and '$(FSharpPrefer64BitTools)' == '' and '$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture)' != 'Arm64'">true</FSharpPreferAnyCpuTools>

        <!-- FSharpPreferAnyCpuTools not yet set, use whatever value FSharpPrefer64BitTools is set to -->
        <FSharpPreferAnyCpuTools Condition="'$(FSharpPreferAnyCpuTools)' == ''">$(FSharpPrefer64BitTools)</FSharpPreferAnyCpuTools>

        <FscToolPath>$(Fsc_NetFramework_ToolPath)</FscToolPath>
        <FscToolExe Condition="'$(FSharpPreferAnyCpuTools)' != 'false'">$(Fsc_NetFramework_AnyCpu_ToolExe)</FscToolExe>
        <FscToolExe Condition="'$(FSharpPreferAnyCpuTools)' == 'false'">$(Fsc_NetFramework_PlatformSpecific_ToolExe)</FscToolExe>

        <DotnetFscCompilerPath></DotnetFscCompilerPath>
    </PropertyGroup>

    <PropertyGroup Condition="'$(FSharp_Shim_Present)' == 'true' and '$(FSharpPreferNetFrameworkTools)' != 'true'">
        <FscToolPath>$(Fsc_Dotnet_ToolPath)</FscToolPath>
        <FscToolExe>$(Fsc_Dotnet_ToolExe)</FscToolExe>
        <DotnetFscCompilerPath>"$(Fsc_Dotnet_DotnetFscCompilerPath)"</DotnetFscCompilerPath>
    </PropertyGroup>

    <PropertyGroup>
      <!-- So that the UI can display default values for these properties, specify values when not set -->
      <FSharpPreferNetFrameworkTools Condition="'$(FSharpPreferNetFrameworkTools)'!='true'">false</FSharpPreferNetFrameworkTools>
      <FSharpPrefer64BitTools Condition="'$(FSharpPrefer64BitTools)'!='false'">true</FSharpPrefer64BitTools>
    </PropertyGroup>

    <!--

      The CreateManifestResourceNames target create the manifest resource names from the .RESX

      files.

      

          [IN]

          @(EmbeddedResource) - The list of EmbeddedResource items that have been pre-processed to add metadata about resource type

                                Expected Metadata "Type" can either be "Resx" or "Non-Resx"



          [OUT]

          @(EmbeddedResource) - EmbeddedResource items with metadata         

          

      For F# applications the transformation is like:



          Resources1.resx => Resources1 => Build into main assembly

          SubFolder\Resources1.resx => SubFolder.Resources1 => Build into main assembly

          Resources1.fr.resx => Resources1.fr => Build into satellite assembly

          Resources1.notaculture.resx => Resources1.notaculture => Build into main assembly



      For other project systems, this transformation may be different.

      -->
    <PropertyGroup>
        <CreateManifestResourceNamesDependsOn></CreateManifestResourceNamesDependsOn>
    </PropertyGroup>

    <PropertyGroup>
        <UsingXBuild>false</UsingXBuild>
        <UsingXBuild Condition="'$(MSBuildAssemblyVersion)' == ''">true</UsingXBuild>
    </PropertyGroup>

    <Target

        Name="CreateManifestResourceNames"

        Condition="'@(EmbeddedResource)' != ''"

        DependsOnTargets="$(CreateManifestResourceNamesDependsOn)"

    >

        <ItemGroup>
            <_Temporary Remove="@(_Temporary)" />
        </ItemGroup>

        <!-- START XBUILD -->

        <!-- This is the implementation of CreateManifestResourceNames which is compatible with the way -->
        <!-- xbuild processes resource names -->

        <CreateFSharpManifestResourceName

             Condition="'@(ResxWithNoCulture)' != '' AND '$(UsingXBuild)' == 'true'"

             UseStandardResourceNames="$(UseStandardResourceNames)"

         ResourceFiles="@(ResxWithNoCulture)" RootNamespace="$(RootNamespace)">
            <Output TaskParameter = "ManifestResourceNames" ItemName = "ManifestResourceWithNoCultureName" />
        </CreateFSharpManifestResourceName>

        <CreateFSharpManifestResourceName

             Condition="'@(NonResxWithNoCulture)' != '' AND '$(UsingXBuild)' == 'true'"

             UseStandardResourceNames="$(UseStandardResourceNames)"

         ResourceFiles="@(NonResxWithNoCulture)" RootNamespace="$(RootNamespace)">
            <Output TaskParameter = "ManifestResourceNames" ItemName = "ManifestNonResxWithNoCulture" />
        </CreateFSharpManifestResourceName>

        <CreateFSharpManifestResourceName

             Condition="'@(ResxWithCulture)' != '' AND '$(UsingXBuild)' == 'true'"

             UseStandardResourceNames="$(UseStandardResourceNames)"

             ResourceFiles="@(ResxWithCulture)" RootNamespace="$(RootNamespace)">
            <Output TaskParameter = "ManifestResourceNames" ItemName = "ManifestResourceWithCultureName" />
        </CreateFSharpManifestResourceName>

        <CreateFSharpManifestResourceName

             Condition="'@(NonResxWithCulture)' != '' AND '$(UsingXBuild)' == 'true'"

             UseStandardResourceNames="$(UseStandardResourceNames)"

             ResourceFiles="@(NonResxWithCulture)" RootNamespace="$(RootNamespace)">
            <Output TaskParameter = "ManifestResourceNames" ItemName = "ManifestNonResxWithCulture" />
        </CreateFSharpManifestResourceName>

        <!-- END XBUILD -->


        <!-- START MSBUILD -->

        <!-- This is the implementation of CreateManifestResourceNames which is compatible with the way -->
        <!-- msbuild processes resource names -->

        <!-- Create manifest names for culture and non-culture Resx files, and for non-culture Non-Resx resources -->
        <CreateFSharpManifestResourceName

              ResourceFiles="@(EmbeddedResource)"

              RootNamespace="$(RootNamespace)"

              UseStandardResourceNames="$(UseStandardResourceNames)"

              Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and ('%(EmbeddedResource.WithCulture)' == 'false' or '%(EmbeddedResource.Type)' == 'Resx') AND '$(UsingXBuild)' == 'false'">

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

        </CreateFSharpManifestResourceName>

        <!-- Create manifest names for all culture non-resx resources -->
        <CreateFSharpManifestResourceName

              ResourceFiles="@(EmbeddedResource)"

              RootNamespace="$(RootNamespace)"

              UseStandardResourceNames="$(UseStandardResourceNames)"

              PrependCultureAsDirectory="false"

              Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx' AND '$(UsingXBuild)' == 'false'">

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

        </CreateFSharpManifestResourceName>
        <!-- END MSBUILD -->

        <ItemGroup>
            <EmbeddedResource Remove="@(EmbeddedResource)" Condition="'%(EmbeddedResource.ManifestResourceName)' == ''"/>
            <EmbeddedResource Include="@(_Temporary)" />
            <_Temporary Remove="@(_Temporary)" />
        </ItemGroup>
    </Target>

    <ItemGroup>
        <DocFileItem Include="$(DocumentationFile)" Condition="'$(DocumentationFile)'!=''"/>
    </ItemGroup>

    <ItemGroup Condition="'$(_DebugSymbolsProduced)' == 'true' and '$(PdbFile)' != ''">
        <_DebugSymbolsIntermediatePathTemporary Include="$(PdbFile)"/>
        <!-- Add any missing .pdb extension, as the compiler does -->
        <_DebugSymbolsIntermediatePath Include="@(_DebugSymbolsIntermediatePathTemporary->'%(RootDir)%(Directory)%(Filename).pdb')"/>
    </ItemGroup>

    <PropertyGroup>
        <CoreCompileDependsOn>_ComputeNonExistentFileProperty</CoreCompileDependsOn>
    </PropertyGroup>

    <Target Name="GenerateFSharpTextResources"

            BeforeTargets="CoreResGen;PrepareForBuild">

        <MakeDir Directories="$(IntermediateOutputPath)" />

        <!-- Generate source for all resx files. -->
        <FSharpEmbedResXSource EmbeddedResource="@(EmbeddedResource)" IntermediateOutputPath="$(IntermediateOutputPath)" TargetFramework="$(TargetFramework)">
            <Output TaskParameter="GeneratedSource" ItemName="_FsGeneratedResXSource" />
        </FSharpEmbedResXSource>

        <ItemGroup>
            <Compile Include="@(_FsGeneratedResXSource)" CompileOrder="CompileBefore" />
            <FsGeneratedSource Include="@(_FsGeneratedResXSource)" />
            <FileWrites Include="@(_FsGeneratedResXSource)" />
        </ItemGroup>

        <!-- Generate resx and source for all txt files. -->
        <FSharpEmbedResourceText EmbeddedText="@(EmbeddedText)" IntermediateOutputPath="$(IntermediateOutputPath)">
            <Output TaskParameter="GeneratedSource" ItemName="_FsGeneratedTxtSource" />
            <Output TaskParameter="GeneratedResx" ItemName="_FsGeneratedResx" />
        </FSharpEmbedResourceText>

        <ItemGroup>
            <Compile Include="@(_FsGeneratedTxtSource)" CompileOrder="CompileBefore" />
            <FsGeneratedSource Include="@(_FsGeneratedTxtSource)" />
            <EmbeddedResource Include="@(_FsGeneratedResx)" />
            <FileWrites Include="@(_FsGeneratedTxtSource)" />
            <FileWrites Include="@(_FsGeneratedResx)" />
        </ItemGroup>
    </Target>

    <Target Name="FSharpSourceCodeCompileOrder">
        <!-- implement <CompileOrder>CompileBefore</CompileOrder> -->
        <ItemGroup>
            <__Sources Remove="@(__Sources)" />
            <__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileFirst'))" />
            <__Sources Include="@(CompileBefore)" />
            <__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileBefore'))" />
            <__Sources Include="@(Compile->WithMetadataValue('CompileOrder', ''))" />
            <__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileAfter'))" />
            <__Sources Include="@(CompileAfter)" />
            <__Sources Include="@(Compile->WithMetadataValue('CompileOrder', 'CompileLast'))" />
        </ItemGroup>
        <ItemGroup>
            <Compile Remove="@(Compile)" />
            <CompileBefore Remove="@(CompileBefore)" />
            <CompileAfter Remove="@(CompileAfter)" />
            <Compile Include="@(__Sources)" />
        </ItemGroup>
        <Message Importance="low" Text="FSharpSourceCodeCompileOrder:Sources: '@(__Sources)'" />
    </Target>

    <Target

        Name="CoreCompile"

        Inputs="$(MSBuildAllProjects);

                @(CompileBefore);

                @(Compile);

                @(CompileAfter);

                @(FscCompilerTools);

                @(_CoreCompileResourceInputs);

                @(ManifestNonResxWithNoCultureOnDisk);

                $(ApplicationIcon);

                $(AssemblyOriginatorKeyFile);

                @(ReferencePathWithRefAssemblies);

                @(CompiledLicenseFile);

                @(EmbeddedDocumentation); 

                $(Win32Resource);

                $(Win32Manifest);

                @(CustomAdditionalCompileInputs);

                $(VersionFile);

                $(KeyOriginatorFile);

                $(UseSource);

                $(LoadSource);

                $(SourceLink)"

        Outputs="@(DocFileItem);

                 @(IntermediateAssembly);

                 @(IntermediateRefAssembly);

                 @(_DebugSymbolsIntermediatePath);

                 $(NonExistentFile);

                 @(CustomAdditionalCompileOutputs)"

        Returns="@(FscCommandLineArgs)"

        DependsOnTargets="$(CoreCompileDependsOn);FSharpSourceCodeCompileOrder"

    >

        <Error

            Condition="'$(SilverlightVersion)' != '' and '$(SilverlightVersion)' != 'v5.0'"

            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#."

        />

        <Warning

            Condition="'$(Win32ResourceFile)' != '' "

            Text="The property &lt;Win32ResourceFile> has been renamed to &lt;Win32Resource>. Update your project file to ensure that the correct value is passed via the --win32res option to the F# compiler."

        />

        <!-- Workaround for differences between how msbuild and xbuild handle embedded resources.

             If we just naively include the additional items needed for mono, that leads to issues

             on msbuild/Windows due to double-including resources.

             Here, we use the $(UsingXBuild) property to conditionally set another property containing the

             correct list of resources based on the build system being used.

             This could be a bit simpler, but xbuild doesn't seem to support msbuild 4.0 'item functions'

             like Distinct().

             Reference: https://github.com/dotnet/fsharp/pull/2595

                        https://github.com/dotnet/fsharp/pull/2605

        -->
        <ItemGroup>
            <ActualEmbeddedResources

                Condition=" '$(UsingXBuild)' == true"

                Include="@(_CoreCompileResourceInputs);@(ManifestResourceWithNoCulture);@(ManifestNonResxWithNoCultureOnDisk);@(CompiledLicenseFile);@(AdditionalEmbeddedResource)" />
          <ActualEmbeddedResources

                Condition=" '$(UsingXBuild)' != true"

                Include="@(_CoreCompileResourceInputs);@(CompiledLicenseFile);@(AdditionalEmbeddedResource)" />
        </ItemGroup>

        <ItemGroup>
            <EmbeddedFiles Include="@(Embed)" KeepDuplicates="false" />
            <EmbeddedFiles Include="@(FsGeneratedSource)"  KeepDuplicates="false" Condition="'$(SourceLink)'!='' or '$(EmbeddedFiles)'!='' or '$(EmbedAllSources)'!=''" />
        </ItemGroup>


        <!-- Dotnet SDK requires SimpleResolution to be true Legacy project system build not -->
        <PropertyGroup>
            <FscOtherFlags Condition="'$(SimpleResolution)' == 'true'">--simpleresolution $(OtherFlags)</FscOtherFlags>
            <FscOtherFlags Condition="'$(SimpleResolution)' != 'true'">$(OtherFlags)</FscOtherFlags>
        </PropertyGroup>

        <!-- Condition is to filter out the _CoreCompileResourceInputs so that it doesn't pass in culture resources to the compiler -->
        <!-- NOTE: ManifestResourceWithNoCulture and ManifestNonResxWithNoCultureOnDisk are generated by Mono targets files -->
        <Fsc  Condition="'%(_CoreCompileResourceInputs.WithCulture)' != 'true'"

              BaseAddress="$(BaseAddress)"

              ChecksumAlgorithm="$(PdbChecksumAlgorithm)"

              CodePage="$(CodePage)"

              CompilerTools="@(FscCompilerTools)"

              CompressMetadata="$(CompressMetadata)"

              DebugSymbols="$(DebugSymbols)"

              DebugType="$(DebugType)"

              DefineConstants="$(DefineConstants)"

              DelaySign="$(DelaySign)"

              Deterministic="$(Deterministic)"

              DisabledWarnings="$(NoWarn)"

              DocumentationFile="$(DocumentationFile)"

              DotnetFscCompilerPath="$(DotnetFscCompilerPath)"

              EmbedAllSources="$(EmbedAllSources)"

              Embed="@(EmbeddedFiles)"

              GenerateInterfaceFile="$(GenerateInterfaceFile)"

              HighEntropyVA="$(HighEntropyVA)"

              KeyFile="$(KeyOriginatorFile)"

              LangVersion="$(LangVersion)"

              LCID="$(LCID)"

              NoFramework="true"

              NoInterfaceData="$(NoInterfaceData)"

              NoOptimizationData="$(NoOptimizationData)"

              Optimize="$(Optimize)"

              ReflectionFree="$(ReflectionFree)"

              OtherFlags="$(FscOtherFlags)"

              OutputAssembly="@(IntermediateAssembly)"

              OutputRefAssembly="@(IntermediateRefAssembly)"

              PathMap="$(PathMap)"

              PdbFile="$(PdbFile)"

              Platform="$(PlatformTarget)"

              Prefer32Bit="$(Actual32Bit)"

              PreferredUILang="$(PreferredUILang)"

              ProvideCommandLineArgs="$(ProvideCommandLineArgs)"

              PublicSign="$(PublicSign)"

              RealSig="$(RealSig)"

              References="@(ReferencePathWithRefAssemblies)"

              ReferencePath="$(ReferencePathWithRefAssemblies)"

              RefOnly="$(ProduceOnlyReferenceAssembly)"

              Resources="@(ActualEmbeddedResources)"

              SkipCompilerExecution="$(SkipCompilerExecution)"

              SourceLink="$(SourceLink)"

              Sources="@(Compile)"

              SubsystemVersion="$(SubsystemVersion)"

              Tailcalls="$(Tailcalls)"

              TargetType="$(OutputType)"

              TargetProfile="$(TargetProfile)"

              ToolExe="$(FscToolExe)"

              ToolPath="$(FscToolPath)"

              TreatWarningsAsErrors="$(TreatWarningsAsErrors)"

              UseStandardResourceNames="$(UseStandardResourceNames)"

              Utf8Output="$(Utf8Output)"

              VersionFile="$(VersionFile)"

              VisualStudioStyleErrors="$(VisualStudioStyleErrors)"

              WarningLevel="$(WarningLevel)"

              WarningsAsErrors="$(WarningsAsErrors)"

              WarningsNotAsErrors="$(WarningsNotAsErrors)"

              WarnOn="$(WarnOn)"

              Win32IconFile="$(ApplicationIcon)"

              Win32ManifestFile="$(Win32Manifest)"

              Win32ResourceFile="$(Win32Resource)">
          <Output TaskParameter="CommandLineArgs" ItemName="FscCommandLineArgs" />
        </Fsc>

        <ItemGroup>
            <_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)" />
        </ItemGroup>

       <CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''" />
    </Target>

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

    <!--

            ============================================================

            GenerateTargetFrameworkMonikerAttribute



            Emit the target framework moniker attribute as  a code 

            fragment into a temporary source file for the compiler.



            ============================================================

    -->

    <Target Name="GenerateTargetFrameworkMonikerAttribute" BeforeTargets="BeforeCompile" DependsOnTargets="PrepareForBuild;GetReferenceAssemblyPaths" Inputs="$(MSBuildThisFileFullPath)" Outputs="$(TargetFrameworkMonikerAssemblyAttributesPath)" Condition="'$(GenerateTargetFrameworkAttribute)' == 'true'">

        <PropertyGroup>
            <!-- This attribute is only available in mscorlib v4 and later -->
            <AdditionalSourcesText Condition="'$(TargetFrameworkMoniker)' != '' and '$(TargetingClr2Framework)' != 'true'">
                $(AdditionalSourcesText)
                namespace Microsoft.BuildSettings
                [&lt;System.Runtime.Versioning.TargetFrameworkAttribute(&quot;$(TargetFrameworkMoniker)&quot;, FrameworkDisplayName=&quot;$(TargetFrameworkMonikerDisplayName)&quot;)&gt;]
                do ()
            </AdditionalSourcesText>
        </PropertyGroup>

        <!-- This is a file shared between projects so we have to take care to handle simultaneous writes (by ContinueOnError)

             and a race between clean from one project and build from another (by not adding to FilesWritten so it doesn't clean) -->
        <WriteLinesToFile

            File="$(TargetFrameworkMonikerAssemblyAttributesPath)"

            Lines="$(AdditionalSourcesText)"

            Condition="'$(AdditionalSourcesText)' != ''"

            ContinueOnError="true"

            Overwrite="true"/>

        <ItemGroup Condition="'$(AdditionalSourcesText)' != ''">
            <Compile Include="$(TargetFrameworkMonikerAssemblyAttributesPath)"><CompileOrder>CompileBefore</CompileOrder></Compile>
            <_FsGeneratedTfmAttributesSource Include="$(TargetFrameworkMonikerAssemblyAttributesPath)" />
        </ItemGroup>
    </Target>

    <!--

    The old reference assemblies are no longer installed to `Program Files (x86)\Reference Assemblies\Microsoft\FSharp`.



    To avoid breaking legacy projects the hint path for FSharp.Core will be rewritten if and only if the existing hint

    path is unchanged from the original legacy templates and if a new reference assembly can be found at the new location.



    -->
    <Target Name="RedirectFSharpCoreReferenceToNewRedistributableLocation" BeforeTargets="ResolveAssemblyReferences">
      <PropertyGroup>
        <_OldRootSdkLocation>$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp</_OldRootSdkLocation>

        <NewFSharpSdkLocation Condition=" '$(NewFSharpSdkLocation)' == '' ">$(VsInstallRoot)\Common7\IDE\CommonExtensions\Microsoft\FSharpSdk</NewFSharpSdkLocation>

        <_CoreRelativeSuffix>.NETCore\$(TargetFSharpCoreVersion)\FSharp.Core.dll</_CoreRelativeSuffix>
        <_FrameworkRelativeSuffix>.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll</_FrameworkRelativeSuffix>
        <_PortableRelativeSuffix>.NETPortable\$(TargetFSharpCoreVersion)\FSharp.Core.dll</_PortableRelativeSuffix>

        <!-- .NETCore -->
        <_OldCoreSdkPath>$(_OldRootSdkLocation)\$(_CoreRelativeSuffix)</_OldCoreSdkPath>
        <_NewCoreSdkPath>$(NewFSharpSdkLocation)\$(_CoreRelativeSuffix)</_NewCoreSdkPath>

        <!-- .NETFramework\v4.0 -->
        <_OldFrameworkSdkPath>$(_OldRootSdkLocation)\$(_FrameworkRelativeSuffix)</_OldFrameworkSdkPath>
        <_NewFrameworkSdkPath>$(NewFSharpSdkLocation)\$(_FrameworkRelativeSuffix)</_NewFrameworkSdkPath>

        <!-- .NETPortable -->
        <_OldPortableSdkPath>$(_OldRootSdkLocation)\$(_PortableRelativeSuffix)</_OldPortableSdkPath>
        <_NewPortableSdkPath>$(NewFSharpSdkLocation)\$(_PortableRelativeSuffix)</_NewPortableSdkPath>
      </PropertyGroup>

      <ItemGroup>
        <!-- Update references to `.NETCore\*\FSharp.Core.dll`. -->
        <Reference Condition="'%(Reference.Identity)' == 'FSharp.Core' and

                              '%(Reference.HintPath)' == '$(_OldCoreSdkPath)' and

                              Exists('$(_NewCoreSdkPath)')">
          <HintPath>$(_NewCoreSdkPath)</HintPath>
        </Reference>

        <!-- Update references to `.NETFramework\v4.0\*\FSharp.Core.dll`. -->
        <Reference Condition="'%(Reference.Identity)' == 'FSharp.Core' and

                              '%(Reference.HintPath)' == '$(_OldFrameworkSdkPath)' and

                              Exists('$(_NewFrameworkSdkPath)')">
          <HintPath>$(_NewFrameworkSdkPath)</HintPath>
        </Reference>

        <!-- Update references to `.Portable\*\FSharp.Core.dll`. -->
        <Reference Condition="'%(Reference.Identity)' == 'FSharp.Core' and

                              '%(Reference.HintPath)' == '$(_OldPortableSdkPath)' and

                              Exists('$(_NewPortableSdkPath)')">
          <HintPath>$(_NewPortableSdkPath)</HintPath>
        </Reference>
      </ItemGroup>
    </Target>

    <Target Name="RedirectTPReferenceToNewRedistributableLocation" BeforeTargets="ResolveAssemblyReferences">
      <PropertyGroup>
        <_OldRefAssemTPLocation>Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.3.0.0\Type Providers\FSharp.Data.TypeProviders.dll</_OldRefAssemTPLocation>
        <_OldSdkTPLocationPrefix>$(MSBuildProgramFiles32)\Microsoft SDKs\F#</_OldSdkTPLocationPrefix>
        <_OldSdkTPLocationSuffix>Framework\v4.0\FSharp.Data.TypeProviders.dll</_OldSdkTPLocationSuffix>
      </PropertyGroup>

      <ItemGroup>
        <!-- Issue error message if there is an inbox TypeProvider referenced.-->
        <ReferenceToInboxTP Include="@(Reference)"

                            Condition="'%(Reference.Identity)' == 'FSharp.Data.TypeProviders' and

                                       $([System.String]::new('%(Reference.HintPath)').EndsWith('$(_OldRefAssemTPLocation)', System.StringComparison.OrdinalIgnoreCase))" />
        <ReferenceToInboxTP Include="@(Reference)"

                            Condition="'%(Reference.Identity)' == 'FSharp.Data.TypeProviders' and

                                       $([System.String]::new('%(Reference.HintPath)').StartsWith('$(_OldSdkTPLocationPrefix)', System.StringComparison.OrdinalIgnoreCase)) and

                                       $([System.String]::new('%(Reference.HintPath)').EndsWith('$(_OldSdkTPLocationSuffix)', System.StringComparison.OrdinalIgnoreCase))" />

      </ItemGroup>
      <Error

          Text="This Project references an obsolete TypeProvider: FSharp.Data.TypeProviders.dll, this was removed In Visual Studio 2019 16.7.0. Consider Switching to the NuGet package version: https://www.nuget.org/packages/FSharp.Data.TypeProviders."

          Condition=" '@(ReferenceToInboxTP->Count())' != '0' " />
    </Target>

    <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter\*" Condition="'$(ImportByWildcardAfterMicrosoftFSharpTargets)' == 'true' and exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter')"/>
</Project>