198 lines
11 KiB
XML
Executable File
198 lines
11 KiB
XML
Executable File
<!-- Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -->
|
|
|
|
<!--
|
|
***********************************************************************************************
|
|
Microsoft.FSharp.NetSdk.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.
|
|
|
|
***********************************************************************************************
|
|
-->
|
|
|
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
<UsingTask TaskName="MapSourceRoots" AssemblyFile="$(FSharpBuildAssemblyFile)" />
|
|
|
|
<PropertyGroup>
|
|
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<AlwaysUseNumericalSuffixInItemNames>true</AlwaysUseNumericalSuffixInItemNames>
|
|
<DefineCommonItemSchemas Condition=" '$(DefineCommonItemSchemas)' == '' ">true</DefineCommonItemSchemas>
|
|
<DefineCommonReferenceSchemas Condition=" '$(DefineCommonReferenceSchemas)' == '' ">true</DefineCommonReferenceSchemas>
|
|
<DefineCommonCapabilities Condition=" '$(DefineCommonCapabilities)' == '' ">true</DefineCommonCapabilities>
|
|
<SimpleResolution>true</SimpleResolution>
|
|
</PropertyGroup>
|
|
|
|
<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>
|
|
|
|
<!-- Locate and add mscorlib, unless NoStdLib is set -->
|
|
<ItemGroup>
|
|
<_ExplicitReference Include="$(FrameworkPathOverride)\mscorlib.dll" Condition=" '$(NoStdLib)' != 'true' " />
|
|
</ItemGroup>
|
|
|
|
<PropertyGroup>
|
|
<TargetProfile Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' " >mscorlib</TargetProfile>
|
|
<TargetProfile Condition=" '$(TargetFrameworkIdentifier)' != '.NETFramework' " >netcore</TargetProfile>
|
|
<TargetProfile Condition=" '$(TargetFrameworkIdentifier)' == '.NETStandard' and '$(_TargetFrameworkVersionWithoutV)' >= '2.0' " >netstandard</TargetProfile>
|
|
</PropertyGroup>
|
|
|
|
<Import Project="Microsoft.FSharp.Targets" />
|
|
|
|
<PropertyGroup Condition="'$(PackProjectInputFile)' == ''">
|
|
<PackProjectInputFile>$(MSBuildProjectFullPath)</PackProjectInputFile>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackageFSharpDesignTimeTools</TargetsForTfmSpecificContentInPackage>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition=" '$(DisableImplicitLibraryPacksFolder)' != 'true' ">
|
|
<RestoreAdditionalProjectSources Condition="Exists('$(_FSharpCoreLibraryPacksFolder)')">$(RestoreAdditionalProjectSources);$(_FSharpCoreLibraryPacksFolder)</RestoreAdditionalProjectSources>
|
|
</PropertyGroup>
|
|
|
|
<Target Name="CollectFSharpDesignTimeTools" BeforeTargets="BeforeCompile" DependsOnTargets="_GetFrameworkAssemblyReferences">
|
|
<ItemGroup>
|
|
<PropertyNames Include = "Pkg$([System.String]::Copy('%(PackageReference.FileName)').Replace('.','_'))" Condition = " '%(PackageReference.IsFSharpDesignTimeProvider)' == 'true' and '%(PackageReference.Extension)' == '' "/>
|
|
<PropertyNames Include = "Pkg$([System.String]::Copy('%(PackageReference.FileName)%(PackageReference.Extension)').Replace('.','_'))" Condition = " '%(PackageReference.IsFSharpDesignTimeProvider)' == 'true' and '%(PackageReference.Extension)' != '' "/>
|
|
<FscCompilerTools Include = "$(%(PropertyNames.Identity))" />
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<Target Name="PackageFSharpDesignTimeTools" DependsOnTargets="_GetFrameworkAssemblyReferences">
|
|
<PropertyGroup>
|
|
<FSharpDesignTimeProtocol Condition = " '$(FSharpDesignTimeProtocol)' == '' ">fsharp41</FSharpDesignTimeProtocol>
|
|
<FSharpToolsDirectory Condition = " '$(FSharpToolsDirectory)' == '' ">tools</FSharpToolsDirectory>
|
|
</PropertyGroup>
|
|
|
|
<Error Text="'$(FSharpToolsDirectory)' is an invalid value for 'FSharpToolsDirectory' valid values are 'typeproviders' and 'tools'." Condition="'$(FSharpToolsDirectory)' != 'typeproviders' and '$(FSharpToolsDirectory)' != 'tools'" />
|
|
<Error Text="The 'FSharpDesignTimeProtocol' property can be only 'fsharp41'" Condition="'$(FSharpDesignTimeProtocol)' != 'fsharp41'" />
|
|
|
|
<ItemGroup>
|
|
<_ResolvedOutputFiles
|
|
Include="%(_ResolvedProjectReferencePaths.RootDir)%(_ResolvedProjectReferencePaths.Directory)/**/*"
|
|
Exclude="%(_ResolvedProjectReferencePaths.RootDir)%(_ResolvedProjectReferencePaths.Directory)/**/FSharp.Core.dll;%(_ResolvedProjectReferencePaths.RootDir)%(_ResolvedProjectReferencePaths.Directory)/**/System.ValueTuple.dll"
|
|
Condition="'%(_ResolvedProjectReferencePaths.IsFSharpDesignTimeProvider)' == 'true'">
|
|
<NearestTargetFramework>%(_ResolvedProjectReferencePaths.NearestTargetFramework)</NearestTargetFramework>
|
|
</_ResolvedOutputFiles>
|
|
|
|
<_ResolvedOutputFiles
|
|
Include="@(BuiltProjectOutputGroupKeyOutput)"
|
|
Condition=" '$(IsFSharpDesignTimeProvider)' == 'true' and '%(BuiltProjectOutputGroupKeyOutput->Filename)%(BuiltProjectOutputGroupKeyOutput->Extension)' != 'FSharp.Core.dll' and '%(BuiltProjectOutputGroupKeyOutput->Filename)%(BuiltProjectOutputGroupKeyOutput->Extension)' != 'System.ValueTuple.dll' ">
|
|
<NearestTargetFramework>$(TargetFramework)</NearestTargetFramework>
|
|
</_ResolvedOutputFiles>
|
|
|
|
<TfmSpecificPackageFile Include="@(_ResolvedOutputFiles)">
|
|
<PackagePath>$(FSharpToolsDirectory)/$(FSharpDesignTimeProtocol)/%(_ResolvedOutputFiles.NearestTargetFramework)/%(_ResolvedOutputFiles.FileName)%(_ResolvedOutputFiles.Extension)</PackagePath>
|
|
</TfmSpecificPackageFile>
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<!--
|
|
The following targets and props for Deterministic Build/SourceRoot mapping were copied from Roslyn:
|
|
https://github.com/dotnet/roslyn/blob/f244a9377cd43685fa56dfa9c9a0b374f4560cd9/src/Compilers/Core/MSBuildTask/Microsoft.Managed.Core.targets#L131-L192
|
|
|
|
The associated build task was added to this project as well and directly used below.
|
|
|
|
When https://github.com/dotnet/msbuild/issues/5398 is resolved these all should be able to be deleted.
|
|
-->
|
|
|
|
<!--
|
|
========================
|
|
DeterministicSourcePaths
|
|
========================
|
|
|
|
Unless specified otherwise enable deterministic source root (PathMap) when building deterministically on CI server, but not for local builds.
|
|
In order for the debugger to find source files when debugging a locally built binary the PDB must contain original, unmapped local paths.
|
|
-->
|
|
<PropertyGroup>
|
|
<DeterministicSourcePaths Condition="'$(DeterministicSourcePaths)' == '' and '$(Deterministic)' == 'true' and '$(ContinuousIntegrationBuild)' == 'true'">true</DeterministicSourcePaths>
|
|
</PropertyGroup>
|
|
|
|
<!--
|
|
==========
|
|
SourceRoot
|
|
==========
|
|
All source files of the project are expected to be located under one of the directories specified by SourceRoot item group.
|
|
This target collects all SourceRoots from various sources.
|
|
This target calculates final local path for each SourceRoot and sets SourceRoot.MappedPath metadata accordingly.
|
|
The final path is a path with deterministic prefix when DeterministicSourcePaths is true, and the original path otherwise.
|
|
In addition, the target validates and deduplicates the SourceRoot items.
|
|
InitializeSourceControlInformation is an msbuild target that ensures the SourceRoot items are populated from source control.
|
|
The target is available only if SourceControlInformationFeatureSupported is true.
|
|
A consumer of SourceRoot.MappedPath metadata, such as Source Link generator, shall depend on this target.
|
|
-->
|
|
|
|
<Target Name="InitializeSourceRootMappedPaths"
|
|
DependsOnTargets="_InitializeSourceRootMappedPathsFromSourceControl"
|
|
Returns="@(SourceRoot)">
|
|
|
|
<ItemGroup Condition="'@(_MappedSourceRoot)' != ''">
|
|
<_MappedSourceRoot Remove="@(_MappedSourceRoot)" />
|
|
</ItemGroup>
|
|
|
|
<MapSourceRoots SourceRoots="@(SourceRoot)" Deterministic="$(DeterministicSourcePaths)">
|
|
<Output TaskParameter="MappedSourceRoots" ItemName="_MappedSourceRoot" />
|
|
</MapSourceRoots>
|
|
|
|
<ItemGroup>
|
|
<SourceRoot Remove="@(SourceRoot)" />
|
|
<SourceRoot Include="@(_MappedSourceRoot)" />
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<!--
|
|
Declare that target InitializeSourceRootMappedPaths that populates MappedPaths metadata on SourceRoot items is available.
|
|
-->
|
|
<PropertyGroup>
|
|
<SourceRootMappedPathsFeatureSupported>true</SourceRootMappedPathsFeatureSupported>
|
|
</PropertyGroup>
|
|
|
|
<!--
|
|
If InitializeSourceControlInformation target isn't supported, we just continue without invoking that synchronization target.
|
|
We'll proceed with SourceRoot (and other source control properties) provided by the user (or blank).
|
|
-->
|
|
<Target Name="_InitializeSourceRootMappedPathsFromSourceControl"
|
|
DependsOnTargets="InitializeSourceControlInformation"
|
|
Condition="'$(SourceControlInformationFeatureSupported)' == 'true'" />
|
|
|
|
<!--
|
|
=======
|
|
PathMap
|
|
=======
|
|
If DeterministicSourcePaths is true sets PathMap based on SourceRoot.MappedPaths.
|
|
This target requires SourceRoot to be initialized in order to calculate the PathMap.
|
|
If SourceRoot doesn't contain any top-level roots an error is reported.
|
|
-->
|
|
|
|
<Target Name="_SetPathMapFromSourceRoots"
|
|
DependsOnTargets="InitializeSourceRootMappedPaths"
|
|
BeforeTargets="CoreCompile"
|
|
Condition="'$(DeterministicSourcePaths)' == 'true'">
|
|
|
|
<ItemGroup>
|
|
<_TopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''">
|
|
<EscapedKey>$([MSBuild]::ValueOrDefault('%(Identity)', '').Replace(',', ',,').Replace('=', '=='))</EscapedKey>
|
|
<EscapedValue>$([MSBuild]::ValueOrDefault('%(MappedPath)', '').Replace(',', ',,').Replace('=', '=='))</EscapedValue>
|
|
</_TopLevelSourceRoot>
|
|
</ItemGroup>
|
|
|
|
<PropertyGroup Condition="'@(_TopLevelSourceRoot)' != ''">
|
|
<!--
|
|
Prepend the SourceRoot.MappedPath values to PathMap, if it already has a value.
|
|
For each emitted source path the compiler applies the first mapping that matches the path.
|
|
PathMap values set previously will thus only be applied if the mapping provided by
|
|
SourceRoot.MappedPath doesn't match. Since SourceRoot.MappedPath is also used by SourceLink
|
|
preferring it over manually set PathMap ensures that PathMap is consistent with SourceLink.
|
|
-->
|
|
<PathMap>@(_TopLevelSourceRoot->'%(EscapedKey)=%(EscapedValue)', ','),$(PathMap)</PathMap>
|
|
</PropertyGroup>
|
|
</Target>
|
|
</Project>
|