提交 4c19c429 编写于 作者: S Steffen Forkmann 提交者: Kevin Ransom (msft)

Make FCS build work on Jenkins (#3788)

上级 d55aa3b8
...@@ -121,3 +121,6 @@ tests/fsharpqa/testenv/bin/System.ValueTuple.dll ...@@ -121,3 +121,6 @@ tests/fsharpqa/testenv/bin/System.ValueTuple.dll
*/.fake */.fake
/fcs/packages/ /fcs/packages/
*/paket-files/ */paket-files/
/fcs/TestResult.xml
/tests/fcs/
/fcs/.paket/Paket.Restore.targets
...@@ -538,10 +538,16 @@ set _ngenexe="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\ngen.exe" ...@@ -538,10 +538,16 @@ set _ngenexe="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\ngen.exe"
if not exist %_ngenexe% echo Error: Could not find ngen.exe. && goto :failure if not exist %_ngenexe% echo Error: Could not find ngen.exe. && goto :failure
echo ---------------- Done with prepare, starting package restore ---------------- echo ---------------- Done with prepare, starting package restore ----------------
set _nugetexe="%~dp0.nuget\NuGet.exe" set _nugetexe="%~dp0.nuget\NuGet.exe"
set _nugetconfig="%~dp0.nuget\NuGet.Config" set _nugetconfig="%~dp0.nuget\NuGet.Config"
if "%RestorePackages%" == "true" ( if "%RestorePackages%" == "true" (
cd fcs
.paket\paket.exe restore
cd..
@if ERRORLEVEL 1 echo Error: Paket restore failed && goto :failure
%_ngenexe% install %_nugetexe% /nologo %_ngenexe% install %_nugetexe% /nologo
%_nugetexe% restore packages.config -PackagesDirectory packages -ConfigFile %_nugetconfig% %_nugetexe% restore packages.config -PackagesDirectory packages -ConfigFile %_nugetconfig%
......
...@@ -412,6 +412,14 @@ _nugetconfig=".nuget/NuGet.Config" ...@@ -412,6 +412,14 @@ _nugetconfig=".nuget/NuGet.Config"
# Restore packages (default to restoring packages if otherwise unspecified). # Restore packages (default to restoring packages if otherwise unspecified).
if [ "${RestorePackages:-true}" = 'true' ]; then if [ "${RestorePackages:-true}" = 'true' ]; then
cd fcs
mono .paket/paket.exe restore
cd ..
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
eval "$_nugetexe restore packages.config -PackagesDirectory packages -ConfigFile $_nugetconfig" eval "$_nugetexe restore packages.config -PackagesDirectory packages -ConfigFile $_nugetconfig"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
failwith "Nuget restore failed" failwith "Nuget restore failed"
......
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Prevent dotnet template engine to parse this file -->
<!--/-:cnd:noEmit-->
<PropertyGroup>
<!-- make MSBuild track this file for incremental builds. -->
<!-- ref https://blogs.msdn.microsoft.com/msbuild/2005/09/26/how-to-ensure-changes-to-a-custom-target-file-prompt-a-rebuild/ -->
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<!-- Mark that this target file has been loaded. -->
<IsPaketRestoreTargetsFileLoaded>true</IsPaketRestoreTargetsFileLoaded>
<PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
<PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath>
<PaketRestoreCacheFile>$(PaketRootPath)paket-files\paket.restore.cached</PaketRestoreCacheFile>
<PaketLockFilePath>$(PaketRootPath)paket.lock</PaketLockFilePath>
<MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
<!-- Paket command -->
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe')">$(PaketRootPath)paket.exe</PaketExePath>
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' AND Exists('$(PaketRootPath)paket.bootstrapper.exe')">$(PaketRootPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
<PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
<PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
<!-- Disable automagic references for F# dotnet sdk -->
<!-- This will not do anything for other project types -->
<!-- see https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-1032-fsharp-in-dotnet-sdk.md -->
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
</PropertyGroup>
<Target Name="PaketRestore" BeforeTargets="_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences" >
<!-- Step 1 Check if lockfile is properly restored -->
<PropertyGroup>
<PaketRestoreRequired>true</PaketRestoreRequired>
<NoWarn>$(NoWarn);NU1603</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="Exists('$(PaketRestoreCacheFile)') ">
<PaketRestoreCachedHash>$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedHash>
<PaketRestoreLockFileHash>$([System.IO.File]::ReadAllText('$(PaketLockFilePath)'))</PaketRestoreLockFileHash>
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '$(PaketRestoreCachedHash)' ">false</PaketRestoreRequired>
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
</PropertyGroup>
<!-- Do a global restore if required -->
<Exec Command='$(PaketBootStrapperCommand)' Condition="Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" ContinueOnError="false" />
<Exec Command='$(PaketCommand) restore' Condition=" '$(PaketRestoreRequired)' == 'true' " ContinueOnError="false" />
<!-- Step 2 Detect project specific changes -->
<PropertyGroup>
<PaketReferencesCachedFilePath>$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).paket.references.cached</PaketReferencesCachedFilePath>
<!-- MyProject.fsproj.paket.references has the highest precedence -->
<PaketOriginalReferencesFilePath>$(MSBuildProjectFullPath).paket.references</PaketOriginalReferencesFilePath>
<!-- MyProject.paket.references -->
<PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketOriginalReferencesFilePath>
<!-- paket.references -->
<PaketOriginalReferencesFilePath Condition=" !Exists('$(PaketOriginalReferencesFilePath)')">$(MSBuildProjectDirectory)\paket.references</PaketOriginalReferencesFilePath>
<PaketResolvedFilePath>$(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).$(TargetFramework).paket.resolved</PaketResolvedFilePath>
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequiredReason>references-file-or-cache-not-found</PaketRestoreRequiredReason>
</PropertyGroup>
<!-- Step 2 a Detect changes in references file -->
<PropertyGroup Condition="Exists('$(PaketOriginalReferencesFilePath)') AND Exists('$(PaketReferencesCachedFilePath)') ">
<PaketRestoreCachedHash>$([System.IO.File]::ReadAllText('$(PaketReferencesCachedFilePath)'))</PaketRestoreCachedHash>
<PaketRestoreReferencesFileHash>$([System.IO.File]::ReadAllText('$(PaketOriginalReferencesFilePath)'))</PaketRestoreReferencesFileHash>
<PaketRestoreRequiredReason>references-file</PaketRestoreRequiredReason>
<PaketRestoreRequired Condition=" '$(PaketRestoreReferencesFileHash)' == '$(PaketRestoreCachedHash)' ">false</PaketRestoreRequired>
</PropertyGroup>
<PropertyGroup Condition="!Exists('$(PaketOriginalReferencesFilePath)') AND !Exists('$(PaketReferencesCachedFilePath)') ">
<!-- If both don't exist there is nothing to do. -->
<PaketRestoreRequired>false</PaketRestoreRequired>
</PropertyGroup>
<!-- Step 2 b detect relevant changes in project file (new targetframework) -->
<PropertyGroup Condition=" !Exists('$(PaketResolvedFilePath)') AND '$(TargetFramework)' != '' ">
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequiredReason>target-framework '$(TargetFramework)'</PaketRestoreRequiredReason>
</PropertyGroup>
<!-- Step 3 Restore project specific stuff if required -->
<Message Condition=" '$(PaketRestoreRequired)' == 'true' " Importance="low" Text="Detected a change ('$(PaketRestoreRequiredReason)') in the project file '$(MSBuildProjectFullPath)', calling paket restore" />
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)"' Condition=" '$(PaketRestoreRequired)' == 'true' " ContinueOnError="false" />
<!-- This shouldn't actually happen, but just to be sure. -->
<Error Condition=" !Exists('$(PaketResolvedFilePath)') AND '$(TargetFramework)' != '' " Text="A paket file for the framework '$(TargetFramework)' is missing. Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." />
<!-- Step 4 forward all msbuild properties (PackageReference, DotNetCliToolReference) to msbuild -->
<ReadLinesFromFile Condition="Exists('$(PaketResolvedFilePath)')" File="$(PaketResolvedFilePath)" >
<Output TaskParameter="Lines" ItemName="PaketReferencesFileLines"/>
</ReadLinesFromFile>
<ItemGroup Condition=" Exists('$(PaketResolvedFilePath)') AND '@(PaketReferencesFileLines)' != '' " >
<PaketReferencesFileLinesInfo Include="@(PaketReferencesFileLines)" >
<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
<PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>
</PaketReferencesFileLinesInfo>
<PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<RestoreConfigFile>$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).NuGet.Config</RestoreConfigFile>
</PropertyGroup>
</Target>
<Target Name="PaketDisableDirectPack" AfterTargets="_IntermediatePack" BeforeTargets="GenerateNuspec" Condition="('$(IsPackable)' == '' Or '$(IsPackable)' == 'true') And Exists('$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).references')" >
<PropertyGroup>
<ContinuePackingAfterGeneratingNuspec>false</ContinuePackingAfterGeneratingNuspec>
</PropertyGroup>
</Target>
<Target Name="PaketOverrideNuspec" AfterTargets="GenerateNuspec" Condition="('$(IsPackable)' == '' Or '$(IsPackable)' == 'true') And Exists('$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).references')" >
<PropertyGroup>
<PaketProjectFile>$(MSBuildProjectDirectory)/$(MSBuildProjectFile)</PaketProjectFile>
<ContinuePackingAfterGeneratingNuspec>true</ContinuePackingAfterGeneratingNuspec>
<UseNewPack>false</UseNewPack>
<UseNewPack Condition=" '$(NuGetToolVersion)' != '4.0.0' ">true</UseNewPack>
</PropertyGroup>
<ItemGroup>
<_NuspecFiles Include="$(BaseIntermediateOutputPath)*.nuspec"/>
</ItemGroup>
<Exec Command='$(PaketCommand) fix-nuspecs files "@(_NuspecFiles)" project-file "$(PaketProjectFile)" ' Condition="@(_NuspecFiles) != ''" />
<ConvertToAbsolutePath Condition="@(_NuspecFiles) != ''" Paths="@(_NuspecFiles)">
<Output TaskParameter="AbsolutePaths" PropertyName="NuspecFileAbsolutePath" />
</ConvertToAbsolutePath>
<!-- Call Pack -->
<PackTask Condition="$(UseNewPack)"
PackItem="$(PackProjectInputFile)"
PackageFiles="@(_PackageFiles)"
PackageFilesToExclude="@(_PackageFilesToExclude)"
PackageVersion="$(PackageVersion)"
PackageId="$(PackageId)"
Title="$(Title)"
Authors="$(Authors)"
Description="$(Description)"
Copyright="$(Copyright)"
RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)"
LicenseUrl="$(PackageLicenseUrl)"
ProjectUrl="$(PackageProjectUrl)"
IconUrl="$(PackageIconUrl)"
ReleaseNotes="$(PackageReleaseNotes)"
Tags="$(PackageTags)"
DevelopmentDependency="$(DevelopmentDependency)"
BuildOutputInPackage="@(_BuildOutputInPackage)"
TargetPathsToSymbols="@(_TargetPathsToSymbols)"
TargetFrameworks="@(_TargetFrameworks)"
AssemblyName="$(AssemblyName)"
PackageOutputPath="$(PackageOutputAbsolutePath)"
IncludeSymbols="$(IncludeSymbols)"
IncludeSource="$(IncludeSource)"
PackageTypes="$(PackageType)"
IsTool="$(IsTool)"
RepositoryUrl="$(RepositoryUrl)"
RepositoryType="$(RepositoryType)"
SourceFiles="@(_SourceFiles->Distinct())"
NoPackageAnalysis="$(NoPackageAnalysis)"
MinClientVersion="$(MinClientVersion)"
Serviceable="$(Serviceable)"
FrameworkAssemblyReferences="@(_FrameworkAssemblyReferences)"
ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
NuspecOutputPath="$(BaseIntermediateOutputPath)"
IncludeBuildOutput="$(IncludeBuildOutput)"
BuildOutputFolder="$(BuildOutputTargetFolder)"
ContentTargetFolders="$(ContentTargetFolders)"
RestoreOutputPath="$(RestoreOutputAbsolutePath)"
NuspecFile="$(NuspecFileAbsolutePath)"
NuspecBasePath="$(NuspecBasePath)"
NuspecProperties="$(NuspecProperties)"/>
<PackTask Condition="! $(UseNewPack)"
PackItem="$(PackProjectInputFile)"
PackageFiles="@(_PackageFiles)"
PackageFilesToExclude="@(_PackageFilesToExclude)"
PackageVersion="$(PackageVersion)"
PackageId="$(PackageId)"
Title="$(Title)"
Authors="$(Authors)"
Description="$(Description)"
Copyright="$(Copyright)"
RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)"
LicenseUrl="$(PackageLicenseUrl)"
ProjectUrl="$(PackageProjectUrl)"
IconUrl="$(PackageIconUrl)"
ReleaseNotes="$(PackageReleaseNotes)"
Tags="$(PackageTags)"
TargetPathsToAssemblies="@(_TargetPathsToAssemblies->'%(FinalOutputPath)')"
TargetPathsToSymbols="@(_TargetPathsToSymbols)"
TargetFrameworks="@(_TargetFrameworks)"
AssemblyName="$(AssemblyName)"
PackageOutputPath="$(PackageOutputAbsolutePath)"
IncludeSymbols="$(IncludeSymbols)"
IncludeSource="$(IncludeSource)"
PackageTypes="$(PackageType)"
IsTool="$(IsTool)"
RepositoryUrl="$(RepositoryUrl)"
RepositoryType="$(RepositoryType)"
SourceFiles="@(_SourceFiles->Distinct())"
NoPackageAnalysis="$(NoPackageAnalysis)"
MinClientVersion="$(MinClientVersion)"
Serviceable="$(Serviceable)"
AssemblyReferences="@(_References)"
ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
NuspecOutputPath="$(BaseIntermediateOutputPath)"
IncludeBuildOutput="$(IncludeBuildOutput)"
BuildOutputFolder="$(BuildOutputTargetFolder)"
ContentTargetFolders="$(ContentTargetFolders)"
RestoreOutputPath="$(RestoreOutputAbsolutePath)"
NuspecFile="$(NuspecFileAbsolutePath)"
NuspecBasePath="$(NuspecBasePath)"
NuspecProperties="$(NuspecProperties)"/>
</Target>
<!--/+:cnd:noEmit-->
</Project>
...@@ -8,18 +8,17 @@ open System.Diagnostics ...@@ -8,18 +8,17 @@ open System.Diagnostics
open System.Text open System.Text
open System.IO open System.IO
open System open System
open System.Xml
type ProjectCracker = module Utils =
static member GetProjectOptionsFromProjectFileLogged(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp, ?enableLogging) =
let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading let Convert loadedTimeStamp (originalOpts: ProjectCrackerTool.ProjectOptions) =
let properties = defaultArg properties []
let enableLogging = defaultArg enableLogging true
let logMap = ref Map.empty let logMap = ref Map.empty
let rec convert (opts: ProjectCrackerTool.ProjectOptions) : FSharpProjectOptions = let rec convertProject (opts: ProjectCrackerTool.ProjectOptions) =
if not (isNull opts.Error) then failwith opts.Error if not (isNull opts.Error) then failwith opts.Error
let referencedProjects = Array.map (fun (a, b) -> a, convert b) opts.ReferencedProjectOptions let referencedProjects() = Array.map (fun (a, b) -> a,convertProject b) opts.ReferencedProjectOptions
let sourceFiles, otherOptions = let sourceFiles, otherOptions =
opts.Options opts.Options
...@@ -41,7 +40,7 @@ type ProjectCracker = ...@@ -41,7 +40,7 @@ type ProjectCracker =
{ ProjectFileName = opts.ProjectFile { ProjectFileName = opts.ProjectFile
SourceFiles = sourceFiles SourceFiles = sourceFiles
OtherOptions = otherOptions OtherOptions = otherOptions
ReferencedProjects = referencedProjects ReferencedProjects = referencedProjects()
IsIncompleteTypeCheckEnvironment = false IsIncompleteTypeCheckEnvironment = false
UseScriptResolutionRules = false UseScriptResolutionRules = false
LoadTime = loadedTimeStamp LoadTime = loadedTimeStamp
...@@ -50,6 +49,16 @@ type ProjectCracker = ...@@ -50,6 +49,16 @@ type ProjectCracker =
ExtraProjectInfo = None ExtraProjectInfo = None
Stamp = None } Stamp = None }
convertProject originalOpts, !logMap
type ProjectCracker =
static member GetProjectOptionsFromProjectFileLogged(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp, ?enableLogging) =
let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading
let properties = defaultArg properties []
let enableLogging = defaultArg enableLogging true
#if NETSTANDARD1_6 #if NETSTANDARD1_6
let arguments = [| let arguments = [|
yield projectFileName yield projectFileName
...@@ -70,20 +79,47 @@ type ProjectCracker = ...@@ -70,20 +79,47 @@ type ProjectCracker =
let codebase = Path.GetDirectoryName(Uri(typeof<ProjectCracker>.Assembly.CodeBase).LocalPath) let codebase = Path.GetDirectoryName(Uri(typeof<ProjectCracker>.Assembly.CodeBase).LocalPath)
let crackerFilename = Path.Combine(codebase,"FSharp.Compiler.Service.ProjectCrackerTool.exe") let crackerFilename = Path.Combine(codebase,"FSharp.Compiler.Service.ProjectCrackerTool.exe")
if not (File.Exists crackerFilename) then failwithf "ProjectCracker exe not found at: %s it must be next to the ProjectCracker dll." crackerFilename if not (File.Exists crackerFilename) then
failwithf "ProjectCracker exe not found at: %s it must be next to the ProjectCracker dll." crackerFilename
let p = new System.Diagnostics.Process() let p = new System.Diagnostics.Process()
p.StartInfo.FileName <- crackerFilename p.StartInfo.FileName <- crackerFilename
p.StartInfo.Arguments <- arguments.ToString() p.StartInfo.Arguments <- arguments.ToString()
p.StartInfo.UseShellExecute <- false p.StartInfo.UseShellExecute <- false
p.StartInfo.CreateNoWindow <- true p.StartInfo.CreateNoWindow <- true
p.StartInfo.RedirectStandardOutput <- true p.StartInfo.RedirectStandardOutput <- true
p.StartInfo.RedirectStandardError <- true
let sbOut = StringBuilder()
let sbErr = StringBuilder()
p.ErrorDataReceived.AddHandler(fun _ a -> sbErr.AppendLine a.Data |> ignore)
p.OutputDataReceived.AddHandler(fun _ a -> sbOut.AppendLine a.Data |> ignore)
ignore <| p.Start() ignore <| p.Start()
p.EnableRaisingEvents <- true
p.BeginOutputReadLine()
p.BeginErrorReadLine()
p.WaitForExit()
let crackerOut = sbOut.ToString()
let crackerErr = sbErr.ToString()
let opts =
try
let ser = new DataContractJsonSerializer(typeof<ProjectCrackerTool.ProjectOptions>) let ser = new DataContractJsonSerializer(typeof<ProjectCrackerTool.ProjectOptions>)
let opts = ser.ReadObject(p.StandardOutput.BaseStream) :?> ProjectCrackerTool.ProjectOptions let stringBytes = Encoding.Unicode.GetBytes crackerOut
use ms = new MemoryStream(stringBytes)
ser.ReadObject(ms) :?> ProjectCrackerTool.ProjectOptions
with
exn ->
raise (Exception(sprintf "error parsing ProjectCrackerTool output, stdoutput was:\n%s\n\nstderr was:\n%s" crackerOut crackerErr, exn))
#endif #endif
convert opts, !logMap Utils.Convert loadedTimeStamp opts
static member GetProjectOptionsFromProjectFile(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp) = static member GetProjectOptionsFromProjectFile(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp) =
fst (ProjectCracker.GetProjectOptionsFromProjectFileLogged( fst (ProjectCracker.GetProjectOptionsFromProjectFileLogged(
......
...@@ -46,24 +46,9 @@ ...@@ -46,24 +46,9 @@
<Compile Include="Program.fs" /> <Compile Include="Program.fs" />
<None Include="App.config" /> <None Include="App.config" />
<None Include="FSharp.Compiler.Service.ProjectCracker.targets" /> <None Include="FSharp.Compiler.Service.ProjectCracker.targets" />
<None Include="paket.references" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>$(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Framework.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.Build.Engine, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>$(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Engine.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>$(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v14.0/Microsoft.Build.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.Build.Utilities.v12.0">
<HintPath>$(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Utilities.v12.0.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="mscorlib" /> <Reference Include="mscorlib" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
...@@ -71,13 +56,75 @@ ...@@ -71,13 +56,75 @@
<Reference Include="System.Numerics" /> <Reference Include="System.Numerics" />
<Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<!-- we build the nuget against FSHarp.Core 4.4.0.0 instead of our latest to allow use in wider range of F# tools --> <!-- we build the nuget against FSHarp.Core 4.4.0.0 instead of our latest to allow use in wider range of F# tools -->
<Reference Include="FSharp.Core"> <Reference Include="FSharp.Core">
<HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll</HintPath> <HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<Import Project="$(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools\Microsoft.FSharp.Targets" /> <Import Project="$(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools\Microsoft.FSharp.Targets" />
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
<ItemGroup>
<Reference Include="Microsoft.Build">
<HintPath>..\packages\Microsoft.Build\lib\net45\Microsoft.Build.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
<ItemGroup>
<Reference Include="Microsoft.Build.Engine">
<HintPath>..\packages\Microsoft.Build.Engine\lib\net45\Microsoft.Build.Engine.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
<ItemGroup>
<Reference Include="Microsoft.Build.Framework">
<HintPath>..\packages\Microsoft.Build.Framework\lib\net45\Microsoft.Build.Framework.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
<ItemGroup>
<Reference Include="Microsoft.Build.Utilities.Core">
<HintPath>..\packages\Microsoft.Build.Utilities.Core\lib\net45\Microsoft.Build.Utilities.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
<ItemGroup>
<Reference Include="System.ComponentModel.Composition">
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
<ItemGroup>
<Reference Include="System.Threading.Tasks.Dataflow">
<HintPath>..\packages\System.Threading.Tasks.Dataflow\lib\portable-net45+win8+wpa81\System.Threading.Tasks.Dataflow.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project> </Project>
\ No newline at end of file
namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool
open System open System
open System.IO open System.Reflection
open System.Runtime.Serialization.Json open System.Runtime.Serialization.Json
module Program = module Program =
[<EntryPoint>] #if !DOTNETCORE
let main argv = let addMSBuildv14BackupResolution () =
let text = Array.exists (fun (s: string) -> s = "--text") argv let onResolveEvent = new ResolveEventHandler(fun sender evArgs ->
let argv = Array.filter (fun (s: string) -> s <> "--text") argv let requestedAssembly = AssemblyName(evArgs.Name)
if requestedAssembly.Name.StartsWith("Microsoft.Build") &&
not (requestedAssembly.Name.EndsWith(".resources")) &&
not (requestedAssembly.Version.ToString().Contains("12.0.0.0"))
then
// If the version of MSBuild that we're using wasn't present on the machine, then
// just revert back to 12.0.0.0 since that's normally installed as part of the .NET
// Framework.
requestedAssembly.Version <- Version("12.0.0.0")
Assembly.Load requestedAssembly
else
null)
AppDomain.CurrentDomain.add_AssemblyResolve(onResolveEvent)
#endif
let crackAndSendOutput asText argv =
let ret, opts = ProjectCrackerTool.crackOpen argv let ret, opts = ProjectCrackerTool.crackOpen argv
if text then if asText then
printfn "%A" opts printfn "%A" opts
else else
let ser = new DataContractJsonSerializer(typeof<ProjectOptions>) let ser = new DataContractJsonSerializer(typeof<ProjectOptions>)
ser.WriteObject(Console.OpenStandardOutput(), opts) ser.WriteObject(Console.OpenStandardOutput(), opts)
ret ret
[<EntryPoint>][<STAThread>]
let main argv =
let asText = Array.exists (fun (s: string) -> s = "--text") argv
let argv = Array.filter (fun (s: string) -> s <> "--text") argv
#if !DOTNETCORE
addMSBuildv14BackupResolution ()
#endif
crackAndSendOutput asText argv
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
open System open System
open System.IO open System.IO
open System.Reflection
open System.Text open System.Text
open Microsoft.Build.Framework open Microsoft.Build.Framework
open Microsoft.Build.Utilities open Microsoft.Build.Utilities
module internal ProjectCrackerTool = module internal ProjectCrackerTool =
open System.Collections.Generic
open Microsoft.Build.Evaluation
let runningOnMono = let runningOnMono =
#if DOTNETCORE #if DOTNETCORE
...@@ -36,82 +37,6 @@ module internal ProjectCrackerTool = ...@@ -36,82 +37,6 @@ module internal ProjectCrackerTool =
member th.Compile(_:obj, _:obj, _:obj) = 0 member th.Compile(_:obj, _:obj, _:obj) = 0
interface ITaskHost interface ITaskHost
//----------------------------------------------------------------------------
// FSharpProjectFileInfo
//
[<Sealed; AutoSerializable(false)>]
type FSharpProjectFileInfo (fsprojFileName:string, ?properties, ?enableLogging) =
let properties = defaultArg properties []
let enableLogging = defaultArg enableLogging false
let mkAbsolute dir v =
if Path.IsPathRooted v then v
else Path.Combine(dir, v)
let logOpt =
if enableLogging then
let log = new BasicStringLogger()
do log.Verbosity <- Microsoft.Build.Framework.LoggerVerbosity.Diagnostic
Some log
else
None
#if !DOTNETCORE
let mkAbsoluteOpt dir v = Option.map (mkAbsolute dir) v
let CrackProjectUsingOldBuildAPI(fsprojFile:string) =
let engine = new Microsoft.Build.BuildEngine.Engine()
Option.iter (fun l -> engine.RegisterLogger(l)) logOpt
let bpg = Microsoft.Build.BuildEngine.BuildPropertyGroup()
bpg.SetProperty("BuildingInsideVisualStudio", "true")
for (prop, value) in properties do
bpg.SetProperty(prop, value)
engine.GlobalProperties <- bpg
let projectFromFile (fsprojFile:string) =
// We seem to need to pass 12.0/4.0 in here for some unknown reason
let project = new Microsoft.Build.BuildEngine.Project(engine, engine.DefaultToolsVersion)
do project.Load(fsprojFile)
project
let project = projectFromFile fsprojFile
project.Build([| "ResolveReferences" |]) |> ignore
let directory = Path.GetDirectoryName project.FullFileName
let getProp (p: Microsoft.Build.BuildEngine.Project) s =
let v = p.GetEvaluatedProperty s
if String.IsNullOrWhiteSpace v then None
else Some v
let outFileOpt =
match mkAbsoluteOpt directory (getProp project "OutDir") with
| None -> None
| Some d -> mkAbsoluteOpt d (getProp project "TargetFileName")
let getItems s =
let fs = project.GetEvaluatedItemsByName(s)
[ for f in fs -> mkAbsolute directory f.FinalItemSpec ]
let projectReferences =
[ for i in project.GetEvaluatedItemsByName("ProjectReference") do
yield mkAbsolute directory i.FinalItemSpec
]
let references =
[ for i in project.GetEvaluatedItemsByName("ReferencePath") do
yield i.FinalItemSpec
for i in project.GetEvaluatedItemsByName("ChildProjectReferences") do
yield i.FinalItemSpec ]
// Duplicate slashes sometimes appear in the output here, which prevents
// them from matching keys used in FSharpProjectOptions.ReferencedProjects
|> List.map (fun (s: string) -> s.Replace("//","/"))
outFileOpt, directory, getItems, references, projectReferences, getProp project, project.FullFileName
#endif
let vs = let vs =
let programFiles = let programFiles =
let getEnv v = let getEnv v =
...@@ -128,7 +53,13 @@ module internal ProjectCrackerTool = ...@@ -128,7 +53,13 @@ module internal ProjectCrackerTool =
let msbuildBin v = IO.Path.Combine(programFiles, "MSBuild", v, "Bin", "MSBuild.exe") let msbuildBin v = IO.Path.Combine(programFiles, "MSBuild", v, "Bin", "MSBuild.exe")
List.tryFind (fun v -> IO.File.Exists(msbuildBin v)) vsVersions List.tryFind (fun v -> IO.File.Exists(msbuildBin v)) vsVersions
let CrackProjectUsingNewBuildAPI(fsprojFile) = let mkAbsolute dir v =
if Path.IsPathRooted v then v
else Path.Combine(dir, v)
let mkAbsoluteOpt dir v = Option.map (mkAbsolute dir) v
let CrackProjectUsingNewBuildAPI fsprojFile properties logOpt =
let fsprojFullPath = try Path.GetFullPath(fsprojFile) with _ -> fsprojFile let fsprojFullPath = try Path.GetFullPath(fsprojFile) with _ -> fsprojFile
let fsprojAbsDirectory = Path.GetDirectoryName fsprojFullPath let fsprojAbsDirectory = Path.GetDirectoryName fsprojFullPath
...@@ -139,15 +70,21 @@ module internal ProjectCrackerTool = ...@@ -139,15 +70,21 @@ module internal ProjectCrackerTool =
member x.Dispose() = Directory.SetCurrentDirectory(dir) } member x.Dispose() = Directory.SetCurrentDirectory(dir) }
use engine = new Microsoft.Build.Evaluation.ProjectCollection() use engine = new Microsoft.Build.Evaluation.ProjectCollection()
let host = new HostCompile() let host = new HostCompile()
engine.HostServices.RegisterHostObject(fsprojFullPath, "CoreCompile", "Fsc", host)
engine.HostServices.RegisterHostObject(fsprojFullPath, "CoreCompile", "Fsc", host)
let projectInstanceFromFullPath (fsprojFullPath: string) = let projectInstanceFromFullPath (fsprojFullPath: string) =
use file = new FileStream(fsprojFullPath, FileMode.Open, FileAccess.Read, FileShare.Read) use file = new FileStream(fsprojFullPath, FileMode.Open, FileAccess.Read, FileShare.Read)
use stream = new StreamReader(file) use stream = new StreamReader(file)
use xmlReader = System.Xml.XmlReader.Create(stream) use xmlReader = System.Xml.XmlReader.Create(stream)
let project = engine.LoadProject(xmlReader, FullPath=fsprojFullPath) let project =
try
engine.LoadProject(xmlReader, FullPath=fsprojFullPath)
with
| exn ->
let tools = engine.Toolsets |> Seq.map (fun x -> x.ToolsPath) |> Seq.toList
raise (new Exception(sprintf "Could not load project %s in ProjectCollection. Available tools: %A. Message: %s" fsprojFullPath tools exn.Message))
project.SetGlobalProperty("BuildingInsideVisualStudio", "true") |> ignore project.SetGlobalProperty("BuildingInsideVisualStudio", "true") |> ignore
if not (List.exists (fun (p,_) -> p = "VisualStudioVersion") properties) then if not (List.exists (fun (p,_) -> p = "VisualStudioVersion") properties) then
...@@ -191,16 +128,87 @@ module internal ProjectCrackerTool = ...@@ -191,16 +128,87 @@ module internal ProjectCrackerTool =
outFileOpt, directory, getItems, references, projectReferences, getprop project, project.FullPath outFileOpt, directory, getItems, references, projectReferences, getprop project, project.FullPath
#if !DOTNETCORE
let CrackProjectUsingOldBuildAPI (fsprojFile:string) properties logOpt =
let engine = new Microsoft.Build.BuildEngine.Engine()
Option.iter (fun l -> engine.RegisterLogger(l)) logOpt
let bpg = Microsoft.Build.BuildEngine.BuildPropertyGroup()
bpg.SetProperty("BuildingInsideVisualStudio", "true")
for (prop, value) in properties do
bpg.SetProperty(prop, value)
engine.GlobalProperties <- bpg
let projectFromFile (fsprojFile:string) =
// We seem to need to pass 12.0/4.0 in here for some unknown reason
let project = new Microsoft.Build.BuildEngine.Project(engine, engine.DefaultToolsVersion)
do project.Load(fsprojFile)
project
let project = projectFromFile fsprojFile
project.Build([| "ResolveReferences" |]) |> ignore
let directory = Path.GetDirectoryName project.FullFileName
let getProp (p: Microsoft.Build.BuildEngine.Project) s =
let v = p.GetEvaluatedProperty s
if String.IsNullOrWhiteSpace v then None
else Some v
let outFileOpt =
match mkAbsoluteOpt directory (getProp project "OutDir") with
| None -> None
| Some d -> mkAbsoluteOpt d (getProp project "TargetFileName")
let getItems s =
let fs = project.GetEvaluatedItemsByName(s)
[ for f in fs -> mkAbsolute directory f.FinalItemSpec ]
let projectReferences =
[ for i in project.GetEvaluatedItemsByName("ProjectReference") do
yield mkAbsolute directory i.FinalItemSpec
]
let references =
[ for i in project.GetEvaluatedItemsByName("ReferencePath") do
yield i.FinalItemSpec
for i in project.GetEvaluatedItemsByName("ChildProjectReferences") do
yield i.FinalItemSpec ]
// Duplicate slashes sometimes appear in the output here, which prevents
// them from matching keys used in FSharpProjectOptions.ReferencedProjects
|> List.map (fun (s: string) -> s.Replace("//","/"))
outFileOpt, directory, getItems, references, projectReferences, getProp project, project.FullFileName
#endif
//----------------------------------------------------------------------------
// FSharpProjectFileInfo
//
[<Sealed; AutoSerializable(false)>]
type FSharpProjectFileInfo (fsprojFileName:string, ?properties, ?enableLogging) =
let properties = defaultArg properties []
let enableLogging = defaultArg enableLogging false
let logOpt =
if enableLogging then
let log = new BasicStringLogger()
do log.Verbosity <- Microsoft.Build.Framework.LoggerVerbosity.Diagnostic
Some log
else
None
let outFileOpt, directory, getItems, references, projectReferences, getProp, fsprojFullPath = let outFileOpt, directory, getItems, references, projectReferences, getProp, fsprojFullPath =
try try
#if DOTNETCORE #if DOTNETCORE
CrackProjectUsingNewBuildAPI(fsprojFileName) CrackProjectUsingNewBuildAPI fsprojFileName properties logOpt
with with
#else #else
if runningOnMono then if runningOnMono then
CrackProjectUsingOldBuildAPI(fsprojFileName) CrackProjectUsingOldBuildAPI fsprojFileName properties logOpt
else else
CrackProjectUsingNewBuildAPI(fsprojFileName) CrackProjectUsingNewBuildAPI fsprojFileName properties logOpt
with with
| :? Microsoft.Build.BuildEngine.InvalidProjectFileException as e -> | :? Microsoft.Build.BuildEngine.InvalidProjectFileException as e ->
raise (Microsoft.Build.Exceptions.InvalidProjectFileException( raise (Microsoft.Build.Exceptions.InvalidProjectFileException(
...@@ -384,8 +392,13 @@ module internal ProjectCrackerTool = ...@@ -384,8 +392,13 @@ module internal ProjectCrackerTool =
static member Parse(fsprojFileName:string, ?properties, ?enableLogging) = new FSharpProjectFileInfo(fsprojFileName, ?properties=properties, ?enableLogging=enableLogging) static member Parse(fsprojFileName:string, ?properties, ?enableLogging) = new FSharpProjectFileInfo(fsprojFileName, ?properties=properties, ?enableLogging=enableLogging)
let getOptions file enableLogging properties = let getOptions file enableLogging properties =
let cache = new Dictionary<_,_>()
let rec getOptions file : Option<string> * ProjectOptions = let rec getOptions file : Option<string> * ProjectOptions =
match cache.TryGetValue file with
| true, option -> option
| _ ->
let parsedProject = FSharpProjectFileInfo.Parse(file, properties=properties, enableLogging=enableLogging) let parsedProject = FSharpProjectFileInfo.Parse(file, properties=properties, enableLogging=enableLogging)
let referencedProjectOptions = let referencedProjectOptions =
[| for file in parsedProject.ProjectReferences do [| for file in parsedProject.ProjectReferences do
if Path.GetExtension(file) = ".fsproj" then if Path.GetExtension(file) = ".fsproj" then
...@@ -423,26 +436,12 @@ module internal ProjectCrackerTool = ...@@ -423,26 +436,12 @@ module internal ProjectCrackerTool =
LogOutput = parsedProject.LogOutput LogOutput = parsedProject.LogOutput
Error = null } Error = null }
parsedProject.OutputFile, options let result = parsedProject.OutputFile, options
cache.Add(file,result)
result
snd (getOptions file) snd (getOptions file)
#if !DOTNETCORE
let addMSBuildv14BackupResolution () =
let onResolveEvent = new ResolveEventHandler(fun sender evArgs ->
let requestedAssembly = AssemblyName(evArgs.Name)
if requestedAssembly.Name.StartsWith("Microsoft.Build") &&
not (requestedAssembly.Name.EndsWith(".resources")) &&
not (requestedAssembly.Version.ToString().Contains("12.0.0.0")) then
// If the version of MSBuild that we're using wasn't present on the machine, then
// just revert back to 12.0.0.0 since that's normally installed as part of the .NET
// Framework.
requestedAssembly.Version <- Version("12.0.0.0")
Assembly.Load (requestedAssembly)
else
null)
AppDomain.CurrentDomain.add_AssemblyResolve(onResolveEvent)
#endif
let rec pairs l = let rec pairs l =
match l with match l with
...@@ -456,9 +455,6 @@ module internal ProjectCrackerTool = ...@@ -456,9 +455,6 @@ module internal ProjectCrackerTool =
| true, true -> true | true, true -> true
| _ -> false | _ -> false
try try
#if !DOTNETCORE
addMSBuildv14BackupResolution ()
#endif
let props = pairs (List.ofArray argv.[2..]) let props = pairs (List.ofArray argv.[2..])
let opts = getOptions argv.[0] enableLogging props let opts = getOptions argv.[0] enableLogging props
0, opts 0, opts
...@@ -466,8 +462,8 @@ module internal ProjectCrackerTool = ...@@ -466,8 +462,8 @@ module internal ProjectCrackerTool =
2, { ProjectFile = projectFile; 2, { ProjectFile = projectFile;
Options = [||]; Options = [||];
ReferencedProjectOptions = [||]; ReferencedProjectOptions = [||];
LogOutput = e.ToString() LogOutput = e.ToString() + " StackTrace: " + e.StackTrace
Error = e.Message } Error = e.Message + " StackTrace: " + e.StackTrace }
else else
1, { ProjectFile = ""; 1, { ProjectFile = "";
Options = [||]; Options = [||];
......
Microsoft.Build.Utilities.Core
Microsoft.Build.Engine
Microsoft.Build
System.Threading.Tasks.Dataflow
\ No newline at end of file
...@@ -80,8 +80,8 @@ ...@@ -80,8 +80,8 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="App.config" /> <None Include="App.config" />
<None Include="paket.references" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="mscorlib" /> <Reference Include="mscorlib" />
<Reference Include="System" /> <Reference Include="System" />
...@@ -97,7 +97,6 @@ ...@@ -97,7 +97,6 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="UIAutomationTypes" /> <Reference Include="UIAutomationTypes" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System.Collections.Immutable"> <Reference Include="System.Collections.Immutable">
<HintPath>$(FSharpSourcesRoot)\..\packages\System.Collections.Immutable.$(SystemCollectionsImmutableVersion)\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath> <HintPath>$(FSharpSourcesRoot)\..\packages\System.Collections.Immutable.$(SystemCollectionsImmutableVersion)\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
...@@ -112,7 +111,6 @@ ...@@ -112,7 +111,6 @@
<HintPath>$(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools\FSharp.Core.dll</HintPath> <HintPath>$(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools\FSharp.Core.dll</HintPath>
<Private>true</Private> <Private>true</Private>
</Reference> </Reference>
<ProjectReference Include="$(FSharpSourcesRoot)\..\tests\service\data\CSharp_Analysis\CSharp_Analysis.csproj"> <ProjectReference Include="$(FSharpSourcesRoot)\..\tests\service\data\CSharp_Analysis\CSharp_Analysis.csproj">
<Name>CSharp_Analysis</Name> <Name>CSharp_Analysis</Name>
<Project>{887630A3-4B1D-40EA-B8B3-2D842E9C40DB}</Project> <Project>{887630A3-4B1D-40EA-B8B3-2D842E9C40DB}</Project>
...@@ -130,4 +128,66 @@ ...@@ -130,4 +128,66 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools\Microsoft.FSharp.Targets" /> <Import Project="$(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools\Microsoft.FSharp.Targets" />
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
<ItemGroup>
<Reference Include="Microsoft.Build">
<HintPath>..\packages\Microsoft.Build\lib\net45\Microsoft.Build.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
<ItemGroup>
<Reference Include="Microsoft.Build.Engine">
<HintPath>..\packages\Microsoft.Build.Engine\lib\net45\Microsoft.Build.Engine.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
<ItemGroup>
<Reference Include="Microsoft.Build.Framework">
<HintPath>..\packages\Microsoft.Build.Framework\lib\net45\Microsoft.Build.Framework.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
<ItemGroup>
<Reference Include="Microsoft.Build.Utilities.Core">
<HintPath>..\packages\Microsoft.Build.Utilities.Core\lib\net45\Microsoft.Build.Utilities.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
<ItemGroup>
<Reference Include="System.Core">
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
<ItemGroup>
<Reference Include="System.ComponentModel.Composition">
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project> </Project>
\ No newline at end of file
Microsoft.Build.Utilities.Core
Microsoft.Build.Engine
Microsoft.Build
\ No newline at end of file
@echo off @echo off
dotnet --version
.nuget\NuGet.exe restore -PackagesDirectory packages
setlocal setlocal
cd fcs cd fcs
dotnet restore tools.fsproj
if errorlevel 1 ( if errorlevel 1 (
endlocal endlocal
exit /b %errorlevel% exit /b %errorlevel%
......
...@@ -13,8 +13,22 @@ open Fake.ReleaseNotesHelper ...@@ -13,8 +13,22 @@ open Fake.ReleaseNotesHelper
#if MONO #if MONO
// prevent incorrect output encoding (e.g. https://github.com/fsharp/FAKE/issues/1196) // prevent incorrect output encoding (e.g. https://github.com/fsharp/FAKE/issues/1196)
System.Console.OutputEncoding <- System.Text.Encoding.UTF8 System.Console.OutputEncoding <- System.Text.Encoding.UTF8
CleanDir (__SOURCE_DIRECTORY__ + "/../tests/TestResults")
File.WriteAllText(__SOURCE_DIRECTORY__ + "/../tests/TestResults/notestsyet.txt","No tests yet")
#endif #endif
let dotnetExePath = DotNetCli.InstallDotNetSDK "2.0.2"
let runDotnet workingDir args =
let result =
ExecProcess (fun info ->
info.FileName <- dotnetExePath
info.WorkingDirectory <- workingDir
info.Arguments <- args) TimeSpan.MaxValue
if result <> 0 then failwithf "dotnet %s failed" args
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// Utilities // Utilities
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
...@@ -69,6 +83,22 @@ let buildVersion = ...@@ -69,6 +83,22 @@ let buildVersion =
else if isAppVeyorBuild then sprintf "%s-b%s" assemblyVersion AppVeyorEnvironment.BuildNumber else if isAppVeyorBuild then sprintf "%s-b%s" assemblyVersion AppVeyorEnvironment.BuildNumber
else assemblyVersion else assemblyVersion
Target "Clean" (fun _ ->
CleanDir releaseDir
)
Target "Restore" (fun _ ->
for p in (!! "./../**/packages.config") do
let result =
ExecProcess (fun info ->
info.FileName <- FullName @"./../.nuget/NuGet.exe"
info.WorkingDirectory <- FullName @"./.."
info.Arguments <- sprintf "restore %s -PackagesDirectory \"%s\" -ConfigFile \"%s\"" (FullName p) (FullName "./../packages") (FullName "./../.nuget/NuGet.Config")) TimeSpan.MaxValue
if result <> 0 then failwithf "nuget restore %s failed" p
runDotnet __SOURCE_DIRECTORY__ "restore tools.fsproj"
)
Target "BuildVersion" (fun _ -> Target "BuildVersion" (fun _ ->
Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" buildVersion) |> ignore Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" buildVersion) |> ignore
) )
...@@ -88,11 +118,24 @@ Target "Build.NetFx" (fun _ -> ...@@ -88,11 +118,24 @@ Target "Build.NetFx" (fun _ ->
// Run the unit tests using test runner // Run the unit tests using test runner
Target "Test.NetFx" (fun _ -> Target "Test.NetFx" (fun _ ->
!! (releaseDir + "/fcs/net45/FSharp.Compiler.Service.Tests.dll") let testDir = __SOURCE_DIRECTORY__ + "/../tests/fcs"
CleanDir testDir
let outDir = releaseDir + "/fcs"
!! (outDir + "/**/*.*")
|> CopyFiles testDir
let toolPath = __SOURCE_DIRECTORY__ + "/../packages/NUnit.Console.3.0.0/tools"
!! (toolPath + "/*.*")
|> CopyFiles testDir
!! (testDir + "/**/FSharp.Compiler.Service.Tests.dll")
|> Fake.Testing.NUnit3.NUnit3 (fun p -> |> Fake.Testing.NUnit3.NUnit3 (fun p ->
{ p with { p with
ToolPath = @"..\packages\NUnit.Console.3.0.0\tools\nunit3-console.exe" ToolPath = testDir + "/nunit3-console.exe"
ShadowCopy = false ShadowCopy = false
WorkingDir = FullName testDir
TimeOut = TimeSpan.FromMinutes 20. }) TimeOut = TimeSpan.FromMinutes 20. })
) )
...@@ -109,26 +152,14 @@ Target "NuGet.NetFx" (fun _ -> ...@@ -109,26 +152,14 @@ Target "NuGet.NetFx" (fun _ ->
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// .NET Core and .NET Core SDK // .NET Core and .NET Core SDK
let isDotnetSDKInstalled =
match Fake.EnvironmentHelper.environVarOrNone "FCS_DNC" with
| Some flag ->
match bool.TryParse flag with
| true, result -> result
| _ -> false
| None ->
try
Shell.Exec("dotnet", "--info") = 0
with
_ -> false
Target "Build.NetStd" (fun _ -> Target "Build.NetStd" (fun _ ->
runCmdIn __SOURCE_DIRECTORY__ "dotnet" "pack %s -v n -c Release" "FSharp.Compiler.Service.netstandard.sln" runDotnet __SOURCE_DIRECTORY__ (sprintf "pack %s -v n -c Release" "FSharp.Compiler.Service.netstandard.sln")
) )
Target "Test.NetStd" (fun _ -> Target "Test.NetStd" (fun _ ->
runCmdIn __SOURCE_DIRECTORY__ "dotnet" "run -p FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj -c Release -- --result:TestResults.NetStd.xml;format=nunit3" runDotnet __SOURCE_DIRECTORY__ (sprintf "run -p FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj -c Release -- --result:TestResults.NetStd.xml;format=nunit3")
) )
...@@ -136,7 +167,7 @@ Target "Test.NetStd" (fun _ -> ...@@ -136,7 +167,7 @@ Target "Test.NetStd" (fun _ ->
Target "Nuget.AddNetStd" (fun _ -> Target "Nuget.AddNetStd" (fun _ ->
let nupkg = sprintf "%s/FSharp.Compiler.Service.%s.nupkg" releaseDir release.AssemblyVersion let nupkg = sprintf "%s/FSharp.Compiler.Service.%s.nupkg" releaseDir release.AssemblyVersion
let netcoreNupkg = sprintf "FSharp.Compiler.Service.netstandard/bin/Release/FSharp.Compiler.Service.%s.nupkg" release.AssemblyVersion let netcoreNupkg = sprintf "FSharp.Compiler.Service.netstandard/bin/Release/FSharp.Compiler.Service.%s.nupkg" release.AssemblyVersion
runCmdIn __SOURCE_DIRECTORY__ "dotnet" "mergenupkg --source %s --other %s --framework netstandard1.6" nupkg netcoreNupkg runDotnet __SOURCE_DIRECTORY__ (sprintf "mergenupkg --source %s --other %s --framework netstandard1.6" nupkg netcoreNupkg)
) )
...@@ -168,7 +199,6 @@ Target "PublishNuGet" (fun _ -> ...@@ -168,7 +199,6 @@ Target "PublishNuGet" (fun _ ->
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build <Target>' to override // Run all targets by default. Invoke 'build <Target>' to override
Target "Clean" DoNothing
Target "Release" DoNothing Target "Release" DoNothing
Target "NuGet" DoNothing Target "NuGet" DoNothing
Target "Build" DoNothing Target "Build" DoNothing
...@@ -177,10 +207,12 @@ Target "TestAndNuGet" DoNothing ...@@ -177,10 +207,12 @@ Target "TestAndNuGet" DoNothing
"Clean" "Clean"
=?> ("BuildVersion", isAppVeyorBuild) =?> ("BuildVersion", isAppVeyorBuild)
==> "Restore"
==> "Build.NetStd" ==> "Build.NetStd"
"Clean" "Clean"
=?> ("BuildVersion", isAppVeyorBuild) =?> ("BuildVersion", isAppVeyorBuild)
==> "Restore"
==> "Build.NetFx" ==> "Build.NetFx"
"Build.NetFx" "Build.NetFx"
...@@ -190,15 +222,15 @@ Target "TestAndNuGet" DoNothing ...@@ -190,15 +222,15 @@ Target "TestAndNuGet" DoNothing
==> "Test.NetStd" ==> "Test.NetStd"
"Build.NetFx" "Build.NetFx"
=?> ("Build.NetStd", isDotnetSDKInstalled) ==> "Build.NetStd"
==> "Build" ==> "Build"
"Build.NetStd" "Build.NetStd"
=?> ("Nuget.AddNetStd", isDotnetSDKInstalled) ==> "Nuget.AddNetStd"
"Build.NetFx" "Build.NetFx"
==> "NuGet.NetFx" ==> "NuGet.NetFx"
=?> ("Nuget.AddNetStd", isDotnetSDKInstalled) ==> "Nuget.AddNetStd"
==> "NuGet" ==> "NuGet"
"Test.NetFx" "Test.NetFx"
...@@ -207,8 +239,6 @@ Target "TestAndNuGet" DoNothing ...@@ -207,8 +239,6 @@ Target "TestAndNuGet" DoNothing
"NuGet" "NuGet"
==> "TestAndNuGet" ==> "TestAndNuGet"
//"Test.NetStd"
// ==> "TestAndNuGet"
"Build" "Build"
==> "NuGet" ==> "NuGet"
......
...@@ -4,10 +4,6 @@ then ...@@ -4,10 +4,6 @@ then
# use .Net # use .Net
cmd fcs/build.cmd $@ cmd fcs/build.cmd $@
else else
dotnet --version
mono .nuget/NuGet.exe restore -PackagesDirectory packages
cd fcs cd fcs
# use mono # use mono
...@@ -15,8 +11,6 @@ else ...@@ -15,8 +11,6 @@ else
mozroots --import --sync --quiet mozroots --import --sync --quiet
fi fi
dotnet restore tools.fsproj
mono .paket/paket.exe restore mono .paket/paket.exe restore
exit_code=$? exit_code=$?
if [ $exit_code -ne 0 ]; then if [ $exit_code -ne 0 ]; then
......
framework: net45 framework: net45, net46
source https://www.nuget.org/api/v2/ source https://www.nuget.org/api/v2/
nuget FAKE nuget FAKE
nuget FSharp.Formatting nuget FSharp.Formatting
nuget Microsoft.Build.Utilities.Core 14.3.0
nuget Microsoft.Build.Framework 14.3.0
nuget Microsoft.Build.Engine 14.3.0
nuget Microsoft.Build 14.3.0
nuget System.Threading.Tasks.Dataflow 4.5.24.0
\ No newline at end of file
RESTRICTION: == net45 RESTRICTION: || (== net45) (== net46)
NUGET NUGET
remote: https://www.nuget.org/api/v2 remote: https://www.nuget.org/api/v2
FAKE (4.63.2) FAKE (4.63.2)
...@@ -8,3 +8,17 @@ NUGET ...@@ -8,3 +8,17 @@ NUGET
FSharpVSPowerTools.Core (>= 2.3 < 2.4) FSharpVSPowerTools.Core (>= 2.3 < 2.4)
FSharpVSPowerTools.Core (2.3) FSharpVSPowerTools.Core (2.3)
FSharp.Compiler.Service (>= 2.0.0.3) FSharp.Compiler.Service (>= 2.0.0.3)
Microsoft.Build (14.3)
Microsoft.Build.Framework (14.3)
Microsoft.Build.Engine (14.3)
Microsoft.Build.Framework (14.3)
Microsoft.Build.Framework (14.3)
System.Collections (>= 4.0.11) - restriction: || (&& (== net45) (>= netstandard1.3)) (== net46)
System.Runtime (>= 4.1) - restriction: || (&& (== net45) (>= netstandard1.3)) (== net46)
System.Runtime.InteropServices (>= 4.1) - restriction: || (&& (== net45) (>= netstandard1.3)) (== net46)
Microsoft.Build.Utilities.Core (14.3)
Microsoft.Build.Framework (14.3)
System.Collections (4.3) - restriction: || (&& (== net45) (>= netstandard1.3)) (== net46)
System.Runtime (4.3) - restriction: || (&& (== net45) (>= netstandard1.3)) (== net46)
System.Runtime.InteropServices (4.3) - restriction: || (&& (== net45) (>= netstandard1.3)) (== net46)
System.Threading.Tasks.Dataflow (4.5.24)
...@@ -20,6 +20,10 @@ open FSharp.Compiler.Service.Tests.Common ...@@ -20,6 +20,10 @@ open FSharp.Compiler.Service.Tests.Common
#if !NO_PROJECTCRACKER #if !NO_PROJECTCRACKER
let hasMSBuild14 =
use engine = new Microsoft.Build.Evaluation.ProjectCollection()
engine.Toolsets |> Seq.exists (fun x -> x.ToolsPath.Contains "v14.0")
let normalizePath s = (new Uri(s)).LocalPath let normalizePath s = (new Uri(s)).LocalPath
let checkOption (opts:string[]) s = let checkOption (opts:string[]) s =
...@@ -90,7 +94,7 @@ let ``Project file parsing example 1 Default configuration relative path`` () = ...@@ -90,7 +94,7 @@ let ``Project file parsing example 1 Default configuration relative path`` () =
[<Test>] [<Test>]
let ``Project file parsing VS2013_FSharp_Portable_Library_net45``() = let ``Project file parsing VS2013_FSharp_Portable_Library_net45``() =
if not runningOnMono then // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok if (not hasMSBuild14) || runningOnMono then () else // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
let projectFile = __SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net45/Sample_VS2013_FSharp_Portable_Library_net45.fsproj" let projectFile = __SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net45/Sample_VS2013_FSharp_Portable_Library_net45.fsproj"
let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, []) let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, [])
...@@ -106,7 +110,7 @@ let ``Project file parsing VS2013_FSharp_Portable_Library_net45``() = ...@@ -106,7 +110,7 @@ let ``Project file parsing VS2013_FSharp_Portable_Library_net45``() =
[<Test>] [<Test>]
let ``Project file parsing Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78``() = let ``Project file parsing Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78``() =
if not runningOnMono then // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok if (not hasMSBuild14) || runningOnMono then () else // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
let projectFile = __SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/Sample_VS2013_FSharp_Portable_Library_net451.fsproj" let projectFile = __SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/Sample_VS2013_FSharp_Portable_Library_net451.fsproj"
Directory.SetCurrentDirectory(__SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/") Directory.SetCurrentDirectory(__SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/")
...@@ -141,7 +145,8 @@ let ``Project file parsing -- bad project file``() = ...@@ -141,7 +145,8 @@ let ``Project file parsing -- bad project file``() =
ProjectCracker.GetProjectOptionsFromProjectFileLogged(f) |> ignore ProjectCracker.GetProjectOptionsFromProjectFileLogged(f) |> ignore
failwith "Expected exception" failwith "Expected exception"
with e -> with e ->
Assert.That(e.Message, Contains.Substring "The project file could not be loaded.") Assert.That(e.Message, Contains.Substring "Could not load project")
Assert.That(e.Message, Contains.Substring "Malformed.fsproj")
[<Test>] [<Test>]
let ``Project file parsing -- non-existent project file``() = let ``Project file parsing -- non-existent project file``() =
...@@ -149,7 +154,7 @@ let ``Project file parsing -- non-existent project file``() = ...@@ -149,7 +154,7 @@ let ``Project file parsing -- non-existent project file``() =
try try
ProjectCracker.GetProjectOptionsFromProjectFileLogged(f, enableLogging=true) |> ignore ProjectCracker.GetProjectOptionsFromProjectFileLogged(f, enableLogging=true) |> ignore
with e -> with e ->
Assert.That(e.Message, Contains.Substring "Could not find file") Assert.That(e.Message, Contains.Substring "DoesNotExist.fsproj")
[<Test>] [<Test>]
let ``Project file parsing -- output file``() = let ``Project file parsing -- output file``() =
...@@ -175,9 +180,20 @@ let ``Project file parsing -- references``() = ...@@ -175,9 +180,20 @@ let ``Project file parsing -- references``() =
references |> should haveLength 4 references |> should haveLength 4
p.ReferencedProjects |> should be Empty p.ReferencedProjects |> should be Empty
[<Test>]
let ``Project file parsing -- no project references``() =
let p = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/Test3.fsproj")
let references = getReferencedFilenames p.OtherOptions
checkOption references "FSharp.Core.dll"
checkOption references "mscorlib.dll"
checkOption references "System.Core.dll"
checkOption references "System.dll"
p.ReferencedProjects |> should haveLength 0
[<Test>] [<Test>]
let ``Project file parsing -- 2nd level references``() = let ``Project file parsing -- 2nd level references``() =
let p = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/Test2.fsproj") let p,_ = ProjectCracker.GetProjectOptionsFromProjectFileLogged(__SOURCE_DIRECTORY__ + @"/data/Test2.fsproj", enableLogging=true)
let references = getReferencedFilenames p.OtherOptions let references = getReferencedFilenames p.OtherOptions
checkOption references "FSharp.Core.dll" checkOption references "FSharp.Core.dll"
...@@ -190,6 +206,7 @@ let ``Project file parsing -- 2nd level references``() = ...@@ -190,6 +206,7 @@ let ``Project file parsing -- 2nd level references``() =
p.ReferencedProjects |> should haveLength 1 p.ReferencedProjects |> should haveLength 1
(snd p.ReferencedProjects.[0]).ProjectFileName |> should contain (normalizePath (__SOURCE_DIRECTORY__ + @"/data/Test1.fsproj")) (snd p.ReferencedProjects.[0]).ProjectFileName |> should contain (normalizePath (__SOURCE_DIRECTORY__ + @"/data/Test1.fsproj"))
[<Test>] [<Test>]
let ``Project file parsing -- reference project output file``() = let ``Project file parsing -- reference project output file``() =
let p = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/DifferingOutputDir/Dir2/Test2.fsproj") let p = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/DifferingOutputDir/Dir2/Test2.fsproj")
...@@ -207,20 +224,23 @@ let ``Project file parsing -- reference project output file``() = ...@@ -207,20 +224,23 @@ let ``Project file parsing -- reference project output file``() =
[<Test>] [<Test>]
let ``Project file parsing -- Tools Version 12``() = let ``Project file parsing -- Tools Version 12``() =
if not hasMSBuild14 then () else
let opts = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj") let opts = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj")
checkOption (getReferencedFilenames opts.OtherOptions) "System.Core.dll" checkOption (getReferencedFilenames opts.OtherOptions) "System.Core.dll"
[<Test>] [<Test>]
let ``Project file parsing -- Logging``() = let ``Project file parsing -- Logging``() =
if not hasMSBuild14 then () else
let projectFileName = normalizePath (__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj") let projectFileName = normalizePath (__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj")
let _, logMap = ProjectCracker.GetProjectOptionsFromProjectFileLogged(projectFileName, enableLogging=true) let _, logMap = ProjectCracker.GetProjectOptionsFromProjectFileLogged(projectFileName, enableLogging=true)
let log = logMap.[projectFileName] let log = logMap.[projectFileName]
Assert.That(log, Is.StringContaining("ResolveAssemblyReference"))
if runningOnMono then if runningOnMono then
Assert.That(log, Is.StringContaining("Reference System.Core resolved")) Assert.That(log, Is.StringContaining("System.Core"))
Assert.That(log, Is.StringContaining("Using task ResolveAssemblyReference from Microsoft.Build.Tasks.ResolveAssemblyReference")) Assert.That(log, Is.StringContaining("Microsoft.Build.Tasks.ResolveAssemblyReference"))
else else
Assert.That(log, Is.StringContaining("""Using "ResolveAssemblyReference" task from assembly "Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".""")) Assert.That(log, Is.StringContaining("Microsoft.Build.Tasks.Core"))
[<Test>] [<Test>]
let ``Project file parsing -- FSharpProjectOptions.SourceFiles contains both fs and fsi files``() = let ``Project file parsing -- FSharpProjectOptions.SourceFiles contains both fs and fsi files``() =
...@@ -237,6 +257,7 @@ let ``Project file parsing -- FSharpProjectOptions.SourceFiles contains both fs ...@@ -237,6 +257,7 @@ let ``Project file parsing -- FSharpProjectOptions.SourceFiles contains both fs
[<Test>] [<Test>]
let ``Project file parsing -- Full path``() = let ``Project file parsing -- Full path``() =
if not hasMSBuild14 then () else
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj") let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj")
let p = ProjectCracker.GetProjectOptionsFromProjectFile(f) let p = ProjectCracker.GetProjectOptionsFromProjectFile(f)
p.ProjectFileName |> should equal f p.ProjectFileName |> should equal f
...@@ -253,6 +274,7 @@ let ``Project file parsing -- project references``() = ...@@ -253,6 +274,7 @@ let ``Project file parsing -- project references``() =
[<Test>] [<Test>]
let ``Project file parsing -- multi language project``() = let ``Project file parsing -- multi language project``() =
if not hasMSBuild14 then () else
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/MultiLanguageProject/ConsoleApplication1.fsproj") let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/MultiLanguageProject/ConsoleApplication1.fsproj")
let options = ProjectCracker.GetProjectOptionsFromProjectFile(f) let options = ProjectCracker.GetProjectOptionsFromProjectFile(f)
...@@ -265,8 +287,7 @@ let ``Project file parsing -- multi language project``() = ...@@ -265,8 +287,7 @@ let ``Project file parsing -- multi language project``() =
[<Test>] [<Test>]
let ``Project file parsing -- PCL profile7 project``() = let ``Project file parsing -- PCL profile7 project``() =
if not runningOnMono then // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok if (not hasMSBuild14) || runningOnMono then () else // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net45/Sample_VS2013_FSharp_Portable_Library_net45.fsproj") let f = normalizePath (__SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net45/Sample_VS2013_FSharp_Portable_Library_net45.fsproj")
...@@ -315,8 +336,7 @@ let ``Project file parsing -- PCL profile7 project``() = ...@@ -315,8 +336,7 @@ let ``Project file parsing -- PCL profile7 project``() =
[<Test>] [<Test>]
let ``Project file parsing -- PCL profile78 project``() = let ``Project file parsing -- PCL profile78 project``() =
if not runningOnMono then // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok if (not hasMSBuild14) || runningOnMono then () else // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/Sample_VS2013_FSharp_Portable_Library_net451.fsproj") let f = normalizePath (__SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/Sample_VS2013_FSharp_Portable_Library_net451.fsproj")
...@@ -356,7 +376,7 @@ let ``Project file parsing -- PCL profile78 project``() = ...@@ -356,7 +376,7 @@ let ``Project file parsing -- PCL profile78 project``() =
[<Test>] [<Test>]
let ``Project file parsing -- PCL profile259 project``() = let ``Project file parsing -- PCL profile259 project``() =
if not runningOnMono then // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok if (not hasMSBuild14) || runningOnMono then () else // Disabled on Mono due to lack of installed PCL reference libraries - the modern way is to reference the FSHarp.Core nuget package so this is ok
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile259/Sample_VS2013_FSharp_Portable_Library_net451.fsproj") let f = normalizePath (__SOURCE_DIRECTORY__ + @"/../projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile259/Sample_VS2013_FSharp_Portable_Library_net451.fsproj")
let options = ProjectCracker.GetProjectOptionsFromProjectFile(f) let options = ProjectCracker.GetProjectOptionsFromProjectFile(f)
...@@ -468,9 +488,11 @@ let ``Test OtherOptions order for GetProjectOptionsFromScript`` () = ...@@ -468,9 +488,11 @@ let ``Test OtherOptions order for GetProjectOptionsFromScript`` () =
projOpts.OtherOptions projOpts.OtherOptions
|> Array.map (fun s -> if s.StartsWith "--" then s else Path.GetFileNameWithoutExtension s) |> Array.map (fun s -> if s.StartsWith "--" then s else Path.GetFileNameWithoutExtension s)
|> Array.sort |> Array.forall (fun s -> Set.contains s expected2)
|> shouldEqual (Array.sort expected2) |> shouldEqual true
let otherArgs = [|"--noframework"; "--warn:3"; "System.Numerics"; "mscorlib"; "FSharp.Core"; "System"; "System.Xml"; "System.Runtime.Remoting"; "System.Runtime.Serialization.Formatters.Soap"; "System.Data"; "System.Drawing"; "System.Core"; "System.Runtime"; "System.Linq"; "System.Reflection"; "System.Linq.Expressions"; "System.Threading.Tasks"; "System.IO"; "System.Net.Requests"; "System.Collections"; "System.Runtime.Numerics"; "System.Threading"; "System.Web"; "System.Web.Services"; "System.Windows.Forms"; "FSharp.Compiler.Interactive.Settings"|]
let otherArgs = [|"--noframework"; "--warn:3"; "System.Numerics"; "mscorlib"; "FSharp.Core"; "System"; "System.Xml"; "System.Runtime.Remoting"; "System.Runtime.Serialization.Formatters.Soap"; "System.Data"; "System.Drawing"; "System.Core"; "System.Runtime"; "System.Linq"; "System.Reflection"; "System.Linq.Expressions"; "System.Threading.Tasks"; "System.IO"; "System.Net.Requests"; "System.Collections"; "System.Runtime.Numerics"; "System.Threading"; "System.Web"; "System.Web.Services"; "System.Windows.Forms"; "FSharp.Compiler.Interactive.Settings"|] |> Set.ofArray
test "Main1" otherArgs test "Main1" otherArgs
test "Main2" otherArgs test "Main2" otherArgs
test "Main3" otherArgs test "Main3" otherArgs
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{116cc2f9-f987-4b3d-915a-34cac04a73db}</ProjectGuid>
<OutputPath>..\..\..\$(Configuration)\net40\bin</OutputPath>
<OutputType>Exe</OutputType>
<RootNamespace>Test2</RootNamespace>
<AssemblyName>Test2</AssemblyName>
<Name>Test2</Name>
<UsePartialTypes>False</UsePartialTypes>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<Tailcalls>False</Tailcalls>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Debug\Test2.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>pdbonly</DebugType>
<Optimize>True</Optimize>
<Tailcalls>True</Tailcalls>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Release\Test2.xml</DocumentationFile>
<DebugSymbols>False</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Test2File2.fs" />
<Compile Include="Test2File1.fs" />
</ItemGroup>
<Import Project="..\..\..\packages\FSharp.Compiler.Tools.4.1.27\tools\Microsoft.FSharp.Targets" />
<Choose>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And $(TargetFrameworkVersion) == 'v1.6') Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And $(TargetFrameworkVersion) == 'v1.0') Or ($(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5')">
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\..\..\packages\NUnit\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册