diff --git a/src/Paket.Core/AddProcess.fs b/src/Paket.Core/AddProcess.fs index ceb43f4572..59b0fa46a8 100644 --- a/src/Paket.Core/AddProcess.fs +++ b/src/Paket.Core/AddProcess.fs @@ -4,7 +4,7 @@ module Paket.AddProcess open Paket open System.IO -let Add(package, version, force, hard, interactive, installAfter) = +let Add(package, version, force, hard, interactive, installAfter, useTargets) = let dependenciesFile = DependenciesFile.ReadFromFile(Constants.DependenciesFile) .Add(package,version) @@ -33,6 +33,6 @@ let Add(package, version, force, hard, interactive, installAfter) = |> File.ReadAllLines |> PackageSourceParser.getSources - InstallProcess.Install(sources, force, hard, lockFile) + InstallProcess.Install(sources, force, hard, lockFile, useTargets) dependenciesFile.Save() \ No newline at end of file diff --git a/src/Paket.Core/InstallProcess.fs b/src/Paket.Core/InstallProcess.fs index c62c355c57..cd8c010abc 100644 --- a/src/Paket.Core/InstallProcess.fs +++ b/src/Paket.Core/InstallProcess.fs @@ -92,7 +92,7 @@ let createModel(sources,force, lockFile:LockFile) = extractedPackages /// Installs the given all packages from the lock file. -let Install(sources,force, hard, lockFile:LockFile) = +let Install(sources,force, hard, lockFile:LockFile, useTargets) = let extractedPackages = createModel(sources,force, lockFile) let model = @@ -110,7 +110,7 @@ let Install(sources,force, hard, lockFile:LockFile) = let usedPackages = lockFile.GetPackageHull(referenceFile) - project.UpdateReferences(model,usedPackages,hard) + project.UpdateReferences(model,usedPackages,hard, useTargets) removeCopiedFiles project diff --git a/src/Paket.Core/NugetConvert.fs b/src/Paket.Core/NugetConvert.fs index 37710c12f0..52364c9945 100644 --- a/src/Paket.Core/NugetConvert.fs +++ b/src/Paket.Core/NugetConvert.fs @@ -125,7 +125,7 @@ let private convertNugetToRefFile(nugetPackagesConfig) = else tracefn "%s is up to date" refFilePath /// Converts all projects from NuGet to Paket -let ConvertFromNuget(force, installAfter, initAutoRestore) = +let ConvertFromNuget(force, installAfter, initAutoRestore, useTargets) = if File.Exists Constants.DependenciesFile && not force then failwithf "%s already exists, use --force to overwrite" Constants.DependenciesFile let nugetPackagesConfigs = FindAllFiles(".", "packages.config") |> Seq.map Nuget.ReadPackagesConfig @@ -179,4 +179,4 @@ let ConvertFromNuget(force, installAfter, initAutoRestore) = VSIntegration.InitAutoRestore() if installAfter then - UpdateProcess.Update(true,false,true) \ No newline at end of file + UpdateProcess.Update(true,false,true, useTargets) \ No newline at end of file diff --git a/src/Paket.Core/ProjectFile.fs b/src/Paket.Core/ProjectFile.fs index 14236e242d..64ace0da55 100644 --- a/src/Paket.Core/ProjectFile.fs +++ b/src/Paket.Core/ProjectFile.fs @@ -237,7 +237,7 @@ type ProjectFile = createItemGroup model.DefaultFallback.References - member this.UpdateReferences(completeModel: Map, usedPackages : Dictionary, hard) = + member this.UpdateReferences(completeModel: Map, usedPackages : Dictionary, hard, useTargets) = this.DeletePaketNodes("Reference") this.DeleteEmptyReferences() @@ -253,8 +253,14 @@ type ProjectFile = if this.HasCustomNodes(installModel) then verbosefn " - custom nodes for %s ==> skipping" packageName else - let chooseNode = this.GenerateXml(installModel) - this.ProjectNode.AppendChild(chooseNode) |> ignore + this.ConfigureReference(installModel, useTargets) + + member private this.ConfigureReference(installModel : InstallModel, useTargets) = + if not useTargets then + let chooseNode = this.GenerateXml(installModel) + this.ProjectNode.AppendChild(chooseNode) |> ignore + else + failwith "--usetargets not implemented" member this.Save() = if Utils.normalizeXml this.Document <> this.OriginalText then diff --git a/src/Paket.Core/RemoveProcess.fs b/src/Paket.Core/RemoveProcess.fs index 32fd642d17..05d70cb2dd 100644 --- a/src/Paket.Core/RemoveProcess.fs +++ b/src/Paket.Core/RemoveProcess.fs @@ -4,7 +4,7 @@ module Paket.RemoveProcess open Paket open System.IO -let Remove(package:string, force, hard, interactive, installAfter) = +let Remove(package:string, force, hard, interactive, installAfter, useTargets) = let allProjects = ProjectFile.FindAllProjects(".") for project in allProjects do let proj = FileInfo(project.FileName) @@ -41,7 +41,7 @@ let Remove(package:string, force, hard, interactive, installAfter) = |> File.ReadAllLines |> PackageSourceParser.getSources - InstallProcess.Install(sources, force, hard, lockFile) + InstallProcess.Install(sources, force, hard, lockFile, useTargets) dependenciesFile.Save() \ No newline at end of file diff --git a/src/Paket.Core/UpdateProcess.fs b/src/Paket.Core/UpdateProcess.fs index 77238d3982..2921b6f1b6 100644 --- a/src/Paket.Core/UpdateProcess.fs +++ b/src/Paket.Core/UpdateProcess.fs @@ -5,7 +5,7 @@ open Paket open System.IO /// Update command -let Update(forceResolution, force, hard) = +let Update(forceResolution, force, hard, useTargets) = let lockFileName = DependenciesFile.FindLockfile Constants.DependenciesFile let sources, lockFile = @@ -25,7 +25,7 @@ let Update(forceResolution, force, hard) = |> PackageSourceParser.getSources sources, LockFile.LoadFrom(lockFileName.FullName) - InstallProcess.Install(sources, force, hard, lockFile) + InstallProcess.Install(sources, force, hard, lockFile, useTargets) let updateWithModifiedDependenciesFile(dependenciesFile:DependenciesFile,package:string, force) = let lockFileName = DependenciesFile.FindLockfile Constants.DependenciesFile @@ -58,9 +58,9 @@ let updateWithModifiedDependenciesFile(dependenciesFile:DependenciesFile,package /// Update a single package command -let UpdatePackage(packageName : string, force, hard) = +let UpdatePackage(packageName : string, force, hard, useTargets) = let lockFileName = DependenciesFile.FindLockfile Constants.DependenciesFile - if not lockFileName.Exists then Update(true, force, hard) else + if not lockFileName.Exists then Update(true, force, hard, useTargets) else let sources, lockFile = let dependenciesFile = DependenciesFile.ReadFromFile Constants.DependenciesFile @@ -82,4 +82,4 @@ let UpdatePackage(packageName : string, force, hard) = LockFile(lockFileName.FullName, updatedDependenciesFile.Options, resolvedPackages, oldLockFile.SourceFiles) newLockFile.Save() updatedDependenciesFile.Sources, newLockFile - InstallProcess.Install(sources, force, hard, lockFile) \ No newline at end of file + InstallProcess.Install(sources, force, hard, lockFile, useTargets) \ No newline at end of file diff --git a/src/Paket/Program.fs b/src/Paket/Program.fs index 633569effd..cc2bf5cc14 100644 --- a/src/Paket/Program.fs +++ b/src/Paket/Program.fs @@ -39,6 +39,7 @@ type CLIArguments = | [] Verbose | [] Interactive | [] Force + | Use_Targets | Hard | [] Nuget of string | [] Version of string @@ -63,6 +64,7 @@ with | Simplify -> "analyzes dependencies and removes unnecessary indirect dependencies." | Verbose -> "displays verbose output." | Force -> "forces the download of all packages." + | Use_Targets -> "use msbuild targets for references." | Interactive -> "interactive process." | Hard -> "overwrites manual package references." | No_Install -> "omits install --hard after convert-from-nuget." @@ -101,6 +103,7 @@ try match results with | Some(command,results) -> let force = results.Contains <@ CLIArguments.Force @> + let useTargets = results.Contains <@ CLIArguments.Use_Targets @> let interactive = results.Contains <@ CLIArguments.Interactive @> let hard = results.Contains <@ CLIArguments.Hard @> let noInstall = results.Contains <@ CLIArguments.No_Install @> @@ -115,22 +118,22 @@ try match results.TryGetResult <@ CLIArguments.Version @> with | Some x -> x | _ -> "" - AddProcess.Add(packageName,version,force,hard,interactive,noInstall |> not) + AddProcess.Add(packageName,version,force,hard,interactive,noInstall |> not,useTargets) | Command.Remove -> let packageName = results.GetResult <@ CLIArguments.Nuget @> - RemoveProcess.Remove(packageName,force,hard,interactive,noInstall |> not) - | Command.Install -> UpdateProcess.Update(false,force,hard) + RemoveProcess.Remove(packageName,force,hard,interactive,noInstall |> not,useTargets) + | Command.Install -> UpdateProcess.Update(false,force,hard,useTargets) | Command.Restore -> let files = results.GetResults <@ CLIArguments.References_Files @> RestoreProcess.Restore(force,files) | Command.Update -> match results.TryGetResult <@ CLIArguments.Nuget @> with - | Some packageName -> UpdateProcess.UpdatePackage(packageName,force,hard) - | _ -> UpdateProcess.Update(true,force,hard) + | Some packageName -> UpdateProcess.UpdatePackage(packageName,force,hard,useTargets) + | _ -> UpdateProcess.Update(true,force,hard,useTargets) | Command.Outdated -> FindOutdated.ListOutdated(strict,includePrereleases) | Command.InitAutoRestore -> VSIntegration.InitAutoRestore() - | Command.ConvertFromNuget -> NuGetConvert.ConvertFromNuget(force,noInstall |> not,noAutoRestore |> not) + | Command.ConvertFromNuget -> NuGetConvert.ConvertFromNuget(force,noInstall |> not,noAutoRestore |> not,useTargets) | Command.Simplify -> Simplifier.Simplify(interactive) | _ -> traceErrorfn "no command given.%s" (parser.Usage())