From 1b0ec87f2b263c46c31486e0e107ebc77debfab9 Mon Sep 17 00:00:00 2001 From: devboy Date: Mon, 2 Mar 2015 16:23:39 +0100 Subject: [PATCH] Add command installs automatically when single project is found and displays a warning when multiple projects are found but interactive command is not given --- RELEASE_NOTES.md | 3 +++ build.fsx | 19 ------------------- src/Paket.Unity3D/AddProcess.fs | 19 ++++++++++++++----- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 3e6c6de..376c143 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 0.0.13 - February 26 2015 +* Add command installs automatically when single project is found and displays a warning when multiple projects are found but interactive command is not given + #### 0.0.12 - February 26 2015 * Implements Add command diff --git a/build.fsx b/build.fsx index 6e02449..f9c8441 100644 --- a/build.fsx +++ b/build.fsx @@ -172,25 +172,6 @@ Target "MergeExe" (fun _ -> if result <> 0 then failwithf "Error during ILRepack execution." ) - -//Target "MergeExe" (fun _ -> -// CreateDir "bin/merge" -// -// let toPack = -// ["paket.unity3d.exe"; "Paket.Core.dll"; "Ionic.Zip.dll"; "Newtonsoft.Json.dll";] -// |> List.map (fun l -> "bin" @@ l) -// |> separated " " -// -// let result = -// ExecProcess (fun info -> -// info.FileName <- currentDirectory @@ "tools" @@ "ILRepack" @@ "ILRepack.exe" -// info.Arguments <- sprintf "/internalize /verbose /lib:%s /ver:%s /out:%s %s" "bin" release.AssemblyVersion ("bin" @@ "merge" @@ "paket.unity3d.exe") toPack -// info.ErrorDialog <- true -// ) (TimeSpan.FromMinutes 5.) -// -// if result <> 0 then failwithf "Error during ILRepack execution." -//) - // -------------------------------------------------------------------------------------- // Build a NuGet package diff --git a/src/Paket.Unity3D/AddProcess.fs b/src/Paket.Unity3D/AddProcess.fs index 5189ab5..57b736e 100644 --- a/src/Paket.Unity3D/AddProcess.fs +++ b/src/Paket.Unity3D/AddProcess.fs @@ -6,6 +6,11 @@ open System.IO open Paket.Domain open Paket.Unity3D +let private add (project:DirectoryInfo) package = + UnityProject.FindOrCreateReferencesFile(project) + .AddNuGetReference(package) + .Save() + let Add(dependenciesFileName, package, version, force, hard, interactive, installAfter) = let existingDependenciesFile = DependenciesFile.ReadFromFile(dependenciesFileName) @@ -22,13 +27,17 @@ let Add(dependenciesFileName, package, version, force, hard, interactive, instal //let lockFile = UpdateProcess.SelectiveUpdate(dependenciesFile,Some(NormalizedPackageName package),force) + let projects = UnityProject.FindAllProjects(Path.GetDirectoryName lockFile.FileName) + if interactive then - let projects = UnityProject.FindAllProjects(Path.GetDirectoryName lockFile.FileName) for project in projects do - if Utils.askYesNo(sprintf " Add to %s?" project.Name) then - UnityProject.FindOrCreateReferencesFile(project) - .AddNuGetReference(package) - .Save() + if Utils.askYesNo(sprintf " Add package to UnityProject: %s at %s?" project.Name project.Parent.FullName) then + add project package + else if projects.Length=1 then + add projects.[0] package + else if projects.Length > 1 then + Paket.Logging.traceWarn "More than one unity project was found, please run interactive mode (--interactive) to pick and choose target project(s)" + // if installAfter then // let sources = dependenciesFile.GetAllPackageSources()