Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--use-targets : switch for using msbuid targets #302

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/Paket.Core/AddProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
4 changes: 2 additions & 2 deletions src/Paket.Core/InstallProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/Paket.Core/NugetConvert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -179,4 +179,4 @@ let ConvertFromNuget(force, installAfter, initAutoRestore) =
VSIntegration.InitAutoRestore()

if installAfter then
UpdateProcess.Update(true,false,true)
UpdateProcess.Update(true,false,true, useTargets)
12 changes: 9 additions & 3 deletions src/Paket.Core/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ type ProjectFile =
createItemGroup model.DefaultFallback.References


member this.UpdateReferences(completeModel: Map<string,InstallModel>, usedPackages : Dictionary<string,bool>, hard) =
member this.UpdateReferences(completeModel: Map<string,InstallModel>, usedPackages : Dictionary<string,bool>, hard, useTargets) =
this.DeletePaketNodes("Reference")
this.DeleteEmptyReferences()

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Paket.Core/RemoveProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
10 changes: 5 additions & 5 deletions src/Paket.Core/UpdateProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
InstallProcess.Install(sources, force, hard, lockFile, useTargets)
15 changes: 9 additions & 6 deletions src/Paket/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type CLIArguments =
| [<AltCommandLine("-v")>] Verbose
| [<AltCommandLine("-i")>] Interactive
| [<AltCommandLine("-f")>] Force
| Use_Targets
| Hard
| [<CustomCommandLine("nuget")>] Nuget of string
| [<CustomCommandLine("version")>] Version of string
Expand All @@ -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."
Expand Down Expand Up @@ -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 @>
Expand All @@ -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())

Expand Down