Skip to content

Commit

Permalink
Locate .paket folder - fixes #152
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Oct 17, 2017
1 parent 90115e8 commit a0554e2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 17 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 0.37.2 - 17.10.2017
* BUGFIX: Try to locate the .paket folder - https://github.com/fsprojects/Paket.VisualStudio/issues/152

#### 0.37.1 - 16.10.2017
* BUGFIX: Fix issues on build/restore packages - https://github.com/fsprojects/Paket.VisualStudio/issues/149

Expand Down
4 changes: 2 additions & 2 deletions src/Paket.VisualStudio/Commands/AddPackageProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public static void ShowAddPackageDialog(string selectedFileName, string projectG
var guid = Guid.Parse(projectGuid);
DteHelper.ExecuteCommand("File.SaveAll");
SolutionExplorerExtensions.UnloadProject(guid);
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "add " + result.PackageName + " --project " + selectedFileName,
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "add " + result.PackageName + " --project " + selectedFileName,
(send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
SolutionExplorerExtensions.ReloadProject(guid);
}
else
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "add " + result.PackageName,
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "add " + result.PackageName,
(send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
};

Expand Down
2 changes: 1 addition & 1 deletion src/Paket.VisualStudio/Restore/PackageRestorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void BuildEvents_OnBuildBegin(vsBuildScope scope, vsBuildAction action)

private void Restore()
{
var dir = SolutionExplorerExtensions.GetSolutionDirectory();
var dir = SolutionExplorerExtensions.GetPaketDirectory();
var dependencies = Dependencies.Locate(dir);

var projects = SolutionExplorerExtensions.GetAllProjects()
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.VisualStudio/Restore/PaketRestorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Restore(IEnumerable<RestoringProject> project)
foreach (RestoringProject p in project)
PaketSubCommand += $" --references-file {p.ReferenceFile} ";

PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), PaketSubCommand,
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), PaketSubCommand,
(send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/Paket.VisualStudio/SolutionExplorer/PaketMenuCommandService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ private void RunCommand(string helpTopic,
PaketErrorPane.Clear();
StatusBarService.UpdateText("Paket command started.");
var info = new SolutionInfo();
info.Directory = SolutionExplorerExtensions.GetSolutionDirectory();
info.FileName = SolutionExplorerExtensions.GetSolutionDirectory();
info.Directory = SolutionExplorerExtensions.GetPaketDirectory();
info.FileName = SolutionExplorerExtensions.GetPaketDirectory();
System.Threading.Tasks.Task.Factory.StartNew(() =>
{
try
Expand Down Expand Up @@ -219,8 +219,8 @@ private void RunCommandAndReloadAllProjects(string helpTopic, Action<SolutionInf
StatusBarService.UpdateText("Paket command started.");

var info = new SolutionInfo();
info.Directory = SolutionExplorerExtensions.GetSolutionDirectory();
info.FileName = SolutionExplorerExtensions.GetSolutionDirectory();
info.Directory = SolutionExplorerExtensions.GetPaketDirectory();
info.FileName = SolutionExplorerExtensions.GetPaketDirectory();
var projectGuids = SolutionExplorerExtensions.GetAllProjectGuids();

SolutionExplorerExtensions.SaveSolution();
Expand Down Expand Up @@ -345,7 +345,7 @@ private void UpdatePackage(object sender, EventArgs e)
{
RunCommandOnPackageAndReloadAllDependendProjects("paket-update.html#Updating-a-single-package", info =>
{
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "update " + info.PackageName,
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "update " + info.PackageName,
(send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
});
}
Expand All @@ -355,7 +355,7 @@ private void UpdateGroup(object sender, EventArgs e)
{
RunCommandOnPackageAndReloadAllDependendProjects("paket-update.html#Updating-a-single-group", info =>
{
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "update --group " + info.GroupName,
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "update --group " + info.GroupName,
(send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
});
}
Expand All @@ -364,7 +364,7 @@ private void RemovePackage(object sender, EventArgs e)
{
RunCommandOnPackageAndReloadAllDependendProjects("paket-remove.html", info =>
{
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "remove " + info.PackageName,
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "remove " + info.PackageName,
(send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
});
}
Expand Down Expand Up @@ -409,7 +409,7 @@ private void RemovePackageFromProject(object sender, EventArgs e)
{
RunCommandOnPackageInUnloadedProject("paket-remove.html#Removing-from-a-single-project", info =>
{
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "remove " + info.PackageName + " --project " + info.ReferencesFileName,
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "remove " + info.PackageName + " --project " + info.ReferencesFileName,
(send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
});
}
Expand All @@ -418,7 +418,7 @@ private void Init(object sender, EventArgs e)
{
RunCommandAndReloadAllProjects("paket-init.html", info =>
{
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "init",
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "init",
(send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
});
}
Expand All @@ -427,7 +427,7 @@ private void ConvertFromNuGet(object sender, EventArgs e)
{
RunCommandAndReloadAllProjects("paket-convert-from-nuget.html", info =>
{
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "convert-from-nuget",
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "convert-from-nuget",
(send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,29 @@ public static string GetSolutionDirectory()
string dir = null;
string fileName = null;
string userOptsFile = null;
IVsSolution solution = _serviceProvider.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SVsSolution)) as IVsSolution;
IVsSolution solution = _serviceProvider.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SVsSolution)) as IVsSolution;

solution.GetSolutionInfo(out dir, out fileName, out userOptsFile);
return dir;
return dir;
}

private static string GetPaketDirectory(DirectoryInfo current, DirectoryInfo sln)
{
var paketFolder = new DirectoryInfo(Path.Combine(current.FullName, ".paket"));
if (paketFolder.Exists)
return current.FullName;
var depsFile = new FileInfo(Path.Combine(current.FullName, "paket.dependencies"));
if (depsFile.Exists)
return current.FullName;
if (current.Parent == null)
return sln.FullName;
return GetPaketDirectory(current.Parent, sln);
}

public static string GetPaketDirectory()
{
var di = new DirectoryInfo(SolutionExplorerExtensions.GetSolutionDirectory());
return GetPaketDirectory(di,di);
}

public static string GetSolutionFileName()
Expand Down Expand Up @@ -120,4 +139,4 @@ private static IEnumerable<Project> GetProjects(Project project)
.SelectMany(p => GetProjects(p.SubProject));
}
}
}
}

0 comments on commit a0554e2

Please sign in to comment.