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

Fix issue 35 #39

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
Binary file modified src/.vs/NuGetReferenceSwitcher.VS17/v15/sqlite3/storage.ide
Binary file not shown.
29 changes: 5 additions & 24 deletions src/NuGetReferenceSwitcher.Presentation/Models/ProjectModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ public bool AddReference(string assemblyPath)
{
if (File.Exists(assemblyPath))
{
var reference = _vsProject.References.Add(assemblyPath) as Reference4;

if (reference != null)
// ReSharper disable once SuspiciousTypeConversion.Global
if (_vsProject.References.Add(assemblyPath) is Reference4 reference)
{
reference.SpecificVersion = true;
}
Expand Down Expand Up @@ -165,31 +164,13 @@ private void LoadReferences()
{
var reference = new ReferenceModel(vsReference);
References.Add(reference);
if (vsReference.Path.ToLower().Contains("/packages/") || vsReference.Path.ToLower().Contains("\\packages\\"))
NuGetReferences.Add(reference);
}
}

public void FixUpNuGetReferences()
{
XDocument xDoc = XDocument.Load(Path);

XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003";

var itemGroup = xDoc.Root?.Elements(ns + "ItemGroup").Where(x => x.Elements(ns + "Reference").Any()).FirstOrDefault();

if (itemGroup != null)
{
foreach (XElement reference in itemGroup.Elements(ns + "Reference").Where(x => x.Elements(ns + "HintPath").Any()))
if (!string.IsNullOrWhiteSpace(vsReference.Path))
{
foreach (XElement version in reference.Elements(ns + "SpecificVersion"))
{
version.Remove();
}
if (vsReference.Path.ToLower().Contains("/packages/") || vsReference.Path.ToLower().Contains("\\packages\\"))
NuGetReferences.Add(reference);
}
}

//xDoc.Save(Path);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using System.Windows;
using System.Windows.Threading;
using EnvDTE;
using EnvDTE80;
using MyToolkit.Build;
using MyToolkit.Collections;
using MyToolkit.Mvvm;
Expand Down Expand Up @@ -208,7 +207,7 @@ private List<ProjectModel> GetAllProjects(IEnumerable<Project> objects)

foreach (var project in objects)
{
if (project.Kind == ProjectKinds.vsProjectKindSolutionFolder)
if (project.Kind == "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}") // folder)
{
projects.AddRange(GetAllProjects(project.ProjectItems
.OfType<ProjectItem>()
Expand Down
6 changes: 3 additions & 3 deletions src/NuGetReferenceSwitcher.VS17/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="87a7b0e9-e41c-47c8-953c-b81650401edc" Version="1.8" Language="en-US" Publisher="RicoSuter" />
<DisplayName>NuGet Reference Switcher for Visual Studio 2017</DisplayName>
<Identity Id="4C57A253-C8B7-4F78-9AE9-FCFDBF544C66" Version="1.9" Language="en-US" Publisher="RicoSuter" />
<DisplayName>NuGet Package Ref Switcher for VS 2017</DisplayName>
<Description xml:space="preserve">Visual Studio extension which automatically switches NuGet assembly references to project references and vice-versa. This is useful when developing applications which reference own NuGet packages: When developing an application, switch to project references so that all code is editable and debuggable. After finishing the development, create new NuGet package versions, switch back to NuGet references and upgrade to the new NuGet versions.</Description>
<MoreInfo>https://nugetreferenceswitcher.codeplex.com</MoreInfo>
<MoreInfo>https://github.com/KwalityKoder/NuGetReferenceSwitcher</MoreInfo>
<Tags>Deployment, NuGet, Dependency management</Tags>
</Metadata>
<Installation InstalledByMsi="false">
Expand Down