Skip to content

Commit

Permalink
Check if a project is already installed before add - references #550
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jan 14, 2015
1 parent 14bd543 commit ec6435b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Paket.Core/AddProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ let Add(dependenciesFileName, package, version, force, hard, interactive, instal

if interactive then
for project in ProjectFile.FindAllProjects(Path.GetDirectoryName lockFile.FileName) do
if Utils.askYesNo(sprintf " Install to %s?" project.Name) then
let notInstalled = project.HasPackageInstalled(NormalizedPackageName package) |> not
if notInstalled && Utils.askYesNo(sprintf " Install to %s?" project.Name) then
ProjectFile.FindOrCreateReferencesFile(FileInfo(project.FileName))
.AddNuGetReference(package)
.Save()
Expand Down
8 changes: 8 additions & 0 deletions src/Paket.Core/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ type ProjectFile =
member this.CreateNode(name) =
this.Document.CreateElement(name, Constants.ProjectDefaultNameSpace)

member this.HasPackageInstalled(package:NormalizedPackageName) =
let proj = FileInfo(this.FileName)
match ProjectFile.FindReferencesFile proj with
| None -> false
| Some fileName ->
let lines = File.ReadAllLines(fileName)
lines |> Seq.exists (fun l -> l.ToLower() = package.ToString().ToLower())

member this.CreateNode(name, text) =
let node = this.CreateNode(name)
node.InnerText <- text
Expand Down
4 changes: 2 additions & 2 deletions src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
<DocumentationFile>
</DocumentationFile>
<StartArguments>update -f</StartArguments>
<StartArguments>restore</StartArguments>
<StartArguments>add nuget NUnit -i</StartArguments>
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartWorkingDirectory>
</StartWorkingDirectory>
<StartWorkingDirectory>d:\code\jsonLD.Entities\src</StartWorkingDirectory>
<StartWorkingDirectory>d:\code\paketkopie</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down

0 comments on commit ec6435b

Please sign in to comment.