Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Move the files over to props
  • Loading branch information
forki committed Jun 29, 2018
commit f5ce16ffa78a717615f5f08edcd91646527bbc01
16 changes: 2 additions & 14 deletions src/Paket.Core/Installation/InstallProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -338,25 +338,13 @@ let private applyBindingRedirects isFirstGroup createNewBindingFiles cleanBindin
|> Seq.sort

applyBindingRedirectsToFolder isFirstGroup createNewBindingFiles cleanBindingRedirects root allKnownLibNames bindingRedirects

let invalidateRestoreCachesForDotnetSdk (projectFileInfo:FileInfo) =
let paketPropsFile = ProjectFile.getPaketPropsFileInfo projectFileInfo
if paketPropsFile.Exists then
let old = File.ReadAllText paketPropsFile.FullName
let newContent = old.Replace("<!-- <RestoreSuccess>False</RestoreSuccess> -->","<RestoreSuccess>False</RestoreSuccess>")
File.WriteAllText(paketPropsFile.FullName, newContent)
let assetsFile = ProjectFile.getAssetsFileInfo projectFileInfo
if assetsFile.Exists then

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Krzysztof-Cieslak @enricosada I'm not sure if this will break the ionide integration. FSAuto was watching the assets file, right? does it watch the props files?

try assetsFile.Delete() with | _ -> ()


let installForDotnetSDK root (project:ProjectFile) =
let paketTargetsPath = RestoreProcess.extractRestoreTargets root
let relativePath = createRelativePath project.FileName paketTargetsPath
project.RemoveImportForPaketTargets()
project.AddImportForPaketTargets(relativePath)
let projectFileInfo = FileInfo(project.FileName)
invalidateRestoreCachesForDotnetSdk (projectFileInfo)


/// Installs all packages from the lock file.
let InstallIntoProjects(options : InstallerOptions, forceTouch, dependenciesFile, lockFile : LockFile, projectsAndReferences : (ProjectFile * ReferencesFile) list, updatedGroups) =
tracefn " - Creating model and downloading packages."
Expand Down
53 changes: 42 additions & 11 deletions src/Paket.Core/Installation/RestoreProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ open Paket.PackageSources
open System
open Chessie.ErrorHandling
open System.Reflection
open Requirements

/// Finds packages which would be affected by a restore, i.e. not extracted yet or with the wrong version
let FindPackagesNotExtractedYet(dependenciesFileName) =
Expand Down Expand Up @@ -255,7 +256,7 @@ let createAlternativeNuGetConfig (projectFile:FileInfo) =

saveToFile config alternativeConfigFileInfo |> ignore

let createPaketPropsFile (cliTools:ResolvedPackage seq) restoreSuccess (fileInfo:FileInfo) =
let createPaketPropsFile (lockFile:LockFile) (cliTools:ResolvedPackage seq) (packages:((GroupName * PackageName) * PackageInstallSettings * _)seq) (fileInfo:FileInfo) =
let cliParts =
if Seq.isEmpty cliTools then
""
Expand All @@ -264,22 +265,49 @@ let createPaketPropsFile (cliTools:ResolvedPackage seq) restoreSuccess (fileInfo
|> Seq.map (fun cliTool -> sprintf """ <DotNetCliToolReference Include="%O" Version="%O" />""" cliTool.Name cliTool.Version)
|> fun xs -> String.Join(Environment.NewLine,xs)
|> fun s -> " <ItemGroup>" + Environment.NewLine + s + Environment.NewLine + " </ItemGroup>"



let packagesParts =
if Seq.isEmpty packages then
""
else
packages
|> Seq.map (fun ((groupName,packageName),_,_) ->
let p = lockFile.Groups.[groupName].Resolution.[packageName]
let condition = Paket.Requirements.getExplicitRestriction p.Settings.FrameworkRestrictions
p,condition)
|> Seq.groupBy snd
|> Seq.collect (fun (condition,packages) ->
let condition = condition.ToMSBuildCondition()
let condition =
if condition = "" || condition = "true" then "" else
sprintf " AND (%s)" condition

let packageReferences =
packages
|> Seq.collect (fun (p,_) ->
[sprintf """ <PackageReference Include="%O">""" p.Name
sprintf """ <Version>%O</Version>""" p.Version
//""" <PrivateAssets Condition=" ('%(PaketReferencesFileLinesInfo.AllPrivateAssets)' == 'true') Or ('$(PackAsTool)' == 'true') ">All</PrivateAssets>""" +
//""" <ExcludeAssets Condition="%(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'exclude'">runtime</ExcludeAssets>""" +
//""" <Publish Condition=" '$(PackAsTool)' == 'true' ">true</Publish>""" +
""" </PackageReference>"""])

[yield sprintf " <ItemGroup Condition=\"($(DesignTimeBuild) == true)%s\">" condition
yield! packageReferences
yield " </ItemGroup>"])
|> fun xs -> String.Join(Environment.NewLine,xs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know that there is a String.concat library routine?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but what would that improve?

@teo-tsirpanis teo-tsirpanis Jun 30, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, nothing actually. 😁 Just to avoid the lambda. I used to not know about the curried version in the past.


let content =
sprintf """<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
%s
</PropertyGroup>
%s
</Project>"""
(if restoreSuccess then
"<!-- <RestoreSuccess>False</RestoreSuccess> -->"
else
"<RestoreSuccess>False</RestoreSuccess>")
%s
</Project>"""
cliParts
packagesParts

saveToFile content fileInfo |> ignore

Expand Down Expand Up @@ -402,14 +430,17 @@ let createProjectReferencesFiles (lockFile:LockFile) (projectFile:ProjectFile) (
loop 5

let cliTools = System.Collections.Generic.List<_>()
let packages = System.Collections.Generic.List<_>()
for kv in groups do
let _,cliToolsInGroup = lockFile.GetOrderedPackageHull(kv.Key,referencesFile)
let packagesInGroup,cliToolsInGroup = lockFile.GetOrderedPackageHull(kv.Key,referencesFile)
cliTools.AddRange cliToolsInGroup
packages.AddRange packagesInGroup

let paketCLIToolsFileName = FileInfo(Path.Combine(projectFileInfo.Directory.FullName,"obj",projectFileInfo.Name + ".paket.clitools"))
createPaketCLIToolsFile cliTools paketCLIToolsFileName

createPaketPropsFile cliTools true (ProjectFile.getPaketPropsFileInfo projectFileInfo)
let propsFile = ProjectFile.getPaketPropsFileInfo projectFileInfo
createPaketPropsFile lockFile cliTools packages propsFile

// Write "cached" file, this way msbuild can check if the references file has changed.
let paketCachedReferencesFileName = FileInfo(Path.Combine(projectFileInfo.Directory.FullName,"obj",projectFileInfo.Name + ".paket.references.cached"))
Expand Down
9 changes: 8 additions & 1 deletion src/Paket.Core/Versioning/Requirements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type FrameworkRestrictionP =
| [] -> "true"
| [single] -> sprintf "%O" single
| _ -> sprintf "&& %s" (System.String.Join(" ", frl |> Seq.map (sprintf "(%O)")))

/// The list represented by this restriction (ie the included set of frameworks)
// NOTE: All critical paths test only if this set is empty, so we use lazy seq here
member x.RepresentedFrameworks =
Expand Down Expand Up @@ -297,6 +297,13 @@ type FrameworkRestriction =
set
member x.IsMatch tp =
x.RawFormular.IsMatch tp

member x.ToMSBuildCondition() =
let formulas =
[for fr in x.RepresentedFrameworks ->
sprintf "('$(TargetFramework)' == '%O')" fr]
String.Join(" OR ",formulas)

override x.Equals(y) =
match y with
| :? FrameworkRestriction as r ->
Expand Down
4 changes: 2 additions & 2 deletions src/Paket.Core/embedded/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@
<Error Condition=" '$(DoAllResolvedFilesExist)' != 'true' AND '$(ResolveNuGetPackages)' != 'False' " Text="One Paket file '@(PaketResolvedFilePaths)' is missing while restoring $(MSBuildProjectFile). Please delete 'paket-files/paket.restore.cached' and call 'paket restore'." />

<!-- Step 4 forward all msbuild properties (PackageReference, DotNetCliToolReference) to msbuild -->
<ReadLinesFromFile Condition="'@(PaketResolvedFilePaths)' != ''" File="%(PaketResolvedFilePaths.Identity)" ><!--Condition="Exists('%(PaketResolvedFilePaths.Identity)')"-->
<ReadLinesFromFile Condition="$(DesignTimeBuild) != true AND '@(PaketResolvedFilePaths)' != ''" File="%(PaketResolvedFilePaths.Identity)" >
<Output TaskParameter="Lines" ItemName="PaketReferencesFileLines"/>
</ReadLinesFromFile>

<ItemGroup Condition=" '@(PaketReferencesFileLines)' != '' " >
<ItemGroup Condition="$(DesignTimeBuild) != true AND '@(PaketReferencesFileLines)' != '' " >
<PaketReferencesFileLinesInfo Include="@(PaketReferencesFileLines)" >
<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
<PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>
Expand Down