Skip to content

Commit da88515

Browse files
Merge pull request #63 from codingadventures/LINQBridgeVs2.0
LINQBridgeVs version 2.0
2 parents df842d8 + 4a3c288 commit da88515

File tree

77 files changed

+535
-2775
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+535
-2775
lines changed

Src/BridgeVs.VsPackage/BridgeVs.VsPackage.csproj renamed to Src/BridgeVs.AsyncVsPackage/BridgeVs.VisualStudio.AsyncExtension.csproj

Lines changed: 175 additions & 216 deletions
Large diffs are not rendered by default.

Src/BridgeVs.VsPackage/LINQBridgeExtension.cs renamed to Src/BridgeVs.AsyncVsPackage/BridgeVsExtension.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@
2828
using System.ComponentModel.Design;
2929
using System.IO;
3030
using System.Linq;
31-
using System.Windows;
32-
using BridgeVs.Shared.Common;
3331
using BridgeVs.VsPackage.Helper;
3432
using BridgeVs.VsPackage.Helper.Command;
3533
using BridgeVs.VsPackage.Helper.Configuration;
3634
using EnvDTE;
3735
using Project = EnvDTE.Project;
3836

39-
namespace BridgeVs.VsPackage
37+
namespace BridgeVs.VisualStudio.AsyncExtension
4038
{
4139
public class BridgeVsExtension
4240
{
@@ -57,6 +55,7 @@ private IEnumerable<Project> AllProjects
5755
{
5856
get
5957
{
58+
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
6059
Projects projects = _application.Solution.Projects;
6160
if (projects == null)
6261
return Enumerable.Empty<Project>();
@@ -71,6 +70,7 @@ where IsSupported(project.UniqueName)
7170

7271
public void Execute(CommandAction action)
7372
{
73+
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
7474
List<Project> projects = AllProjects.ToList();
7575

7676
if (projects.Count == 0)
@@ -79,12 +79,12 @@ public void Execute(CommandAction action)
7979
if (BridgeCommand.IsEveryProjectSupported(projects, _application.Version, _application.Edition))
8080
{
8181
BridgeCommand.ActivateBridgeVsOnSolution(action, projects, SolutionName, _application.Version,
82-
_application.Edition);
82+
_application.Edition, Path.GetDirectoryName(_application.Solution.FileName));
8383
}
8484
else
8585
{
8686
string message = $@"Solution {SolutionName} contains one or more un-supported projects. ASP.NET Core, .NET Core, .NET standard and UAP are not supported by LINQBridgeVs.";
87-
MessageBox.Show(message);
87+
System.Windows.MessageBox.Show(message);
8888
}
8989
}
9090

@@ -97,14 +97,18 @@ public void UpdateCommand(MenuCommand cmd, CommandAction action)
9797

9898
private CommandStates GetStatus(CommandAction action)
9999
{
100+
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
101+
100102
CommandStates result = CommandStates.Visible;
101103

102104
bool isBridgeVsConfigured = PackageConfigurator.IsBridgeVsConfigured(_application.Version);
103105

104106
if (!isBridgeVsConfigured)
105107
return result; //just show it as visible
106108

107-
bool isSolutionEnabled = CommonRegistryConfigurations.IsSolutionEnabled(SolutionName, _application.Version);
109+
string solutionDir = Path.GetDirectoryName(_application.Solution.FileName);
110+
string directoryTarget = Path.Combine(solutionDir, "Directory.Build.targets");
111+
bool isSolutionEnabled = File.Exists(directoryTarget);
108112

109113
if (isSolutionEnabled && action == CommandAction.Disable || !isSolutionEnabled && action == CommandAction.Enable)
110114
result |= CommandStates.Enabled;

Src/BridgeVs.VsPackage.Helper/Command/BridgeCommand.cs renamed to Src/BridgeVs.AsyncVsPackage/Command/BridgeCommand.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#endregion
2525

2626
using BridgeVs.Shared.Common;
27+
using BridgeVs.Shared.FileSystem;
28+
using BridgeVs.VsPackage.Helper.Configuration;
2729
using EnvDTE;
2830
using System;
2931
using System.Collections.Generic;
@@ -36,6 +38,7 @@ namespace BridgeVs.VsPackage.Helper.Command
3638
{
3739
public static class BridgeCommand
3840
{
41+
private const string DirectoryBuildTargets = "Directory.Build.targets";
3942
private static readonly List<string> UnsupportedFrameworks = new List<string>(20)
4043
{
4144
"netstandard",
@@ -51,8 +54,11 @@ public static class BridgeCommand
5154

5255
public static void ActivateBridgeVsOnSolution(CommandAction action, List<Project> projects, string solutionName,
5356
string vsVersion,
54-
string vsEdition)
57+
string vsEdition,
58+
string solutionFolder)
5559
{
60+
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
61+
5662
List<BridgeProjectInfo> executeParams = new List<BridgeProjectInfo>();
5763

5864
//enable each individual project by mapping the assembly name and location to a registry entry
@@ -70,6 +76,7 @@ public static void ActivateBridgeVsOnSolution(CommandAction action, List<Project
7076
if (project.Object is VSProject vsProject && vsProject.References != null)
7177
{
7278
references = from Reference reference in vsProject.References
79+
where reference.Path != null
7380
where reference.SourceProject == null //it means it's an assembly reference
7481
where !reference.Path.Contains(".NETFramework") && !reference.Path.Contains("Microsoft") //no .net framework assembly
7582
select reference.Path;
@@ -83,9 +90,14 @@ public static void ActivateBridgeVsOnSolution(CommandAction action, List<Project
8390
{
8491
case CommandAction.Enable:
8592
CommonRegistryConfigurations.BridgeSolution(solutionName, vsVersion, executeParams);
93+
//copy directory build target to the solution folder
94+
string target = PackageConfigurator.GetInstallationFolder(vsVersion);
95+
File.Copy(Path.Combine(target, "Targets", DirectoryBuildTargets), Path.Combine(solutionFolder, DirectoryBuildTargets), true);
8696
break;
8797
case CommandAction.Disable:
8898
CommonRegistryConfigurations.UnBridgeSolution(solutionName, vsVersion);
99+
//delete directory build target
100+
File.Delete(Path.Combine(solutionFolder, DirectoryBuildTargets));
89101
break;
90102
}
91103

@@ -99,6 +111,8 @@ public static void ActivateBridgeVsOnSolution(CommandAction action, List<Project
99111
public static bool IsEveryProjectSupported(List<Project> projects, string applicationVersion,
100112
string applicationEdition)
101113
{
114+
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
115+
102116
foreach (Project project in projects)
103117
{
104118
string targetFramework = project.Properties.Item("TargetFrameworkMoniker").Value.ToString();

Src/BridgeVs.VsPackage.Helper/Configuration/MsBuildVersionHelper.cs renamed to Src/BridgeVs.AsyncVsPackage/Configuration/MsBuildVersionHelper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public static string GetMsBuildVersion(string vsVersion)
4141
return "v14.0";
4242
case "15.0":
4343
return "v15.0";
44+
case "16.0":
45+
return "v16.0";
4446
default :
4547
throw new ArgumentException("Visual Studio Version not Supported", nameof(vsVersion));
4648
}

Src/BridgeVs.VsPackage.Helper/Configuration/PackageConfigurator.cs renamed to Src/BridgeVs.AsyncVsPackage/Configuration/PackageConfigurator.cs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
using System.Security.Principal;
3333
using System.Windows.Forms;
3434
using BridgeVs.Shared.Common;
35+
using BridgeVs.VisualStudio.AsyncExtension.Configuration;
3536
using Microsoft.Win32;
3637
using OpenFileDialog = System.Windows.Forms.OpenFileDialog;
3738

@@ -121,20 +122,6 @@ private static bool IsLINQPadInstalled(string vsVersion)
121122
return false;
122123
}
123124

124-
private static void DeployMsBuildTargets(string vsVersion, string vsEdition)
125-
{
126-
string msBuildDir = CreateMsBuildTargetDirectory(vsVersion, vsEdition);
127-
//Copy the CustomAfter and CustomBefore to the default MSBuild v4.0 location
128-
File.Copy(CommonFolderPaths.CustomAfterTargetFileNamePath, Path.Combine(msBuildDir, CommonFolderPaths.CustomAfterTargetFileName), true);
129-
130-
string customBeforeTarget = Path.Combine(msBuildDir, CommonFolderPaths.CustomBeforeTargetFileName);
131-
if (File.Exists(customBeforeTarget)) //old before target, now obsolete
132-
{
133-
File.Delete(customBeforeTarget);
134-
}
135-
136-
}
137-
138125
private static void SetInstallationFolder(string vsVersion)
139126
{
140127
//Set in the registry the installer location if it is has changed
@@ -151,7 +138,7 @@ private static void SetInstallationFolder(string vsVersion)
151138
}
152139
}
153140

154-
private static string GetInstallationFolder(string vsVersion)
141+
public static string GetInstallationFolder(string vsVersion)
155142
{
156143
//Set in the registry the installer location if it is has changed
157144
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(CommonRegistryConfigurations.GetRegistryKey(Resources.ProductRegistryKey, vsVersion)))
@@ -235,8 +222,6 @@ public static bool Install(string vsVersion, string vsEdition)
235222
//Always check if installation folder has changed
236223
SetInstallationFolder(vsVersion);
237224

238-
DeployMsBuildTargets(vsVersion, vsEdition);
239-
240225
GenerateGuidForCurrentInstallation(vsVersion);
241226

242227
DeleteExistingVisualizers(vsVersion);
@@ -314,6 +299,10 @@ private static string DebuggerVisualizerTargetFolder(string vsVersion)
314299
case "15.0":
315300
debuggerVisualizerTargetFolder = CommonFolderPaths.Vs2017DebuggerVisualizerDestinationFolder;
316301
break;
302+
case "16.0":
303+
debuggerVisualizerTargetFolder = CommonFolderPaths.Vs2019DebuggerVisualizerDestinationFolder;
304+
break;
305+
317306
}
318307

319308
return debuggerVisualizerTargetFolder;

Src/BridgeVs.VsPackage.Helper/Configuration/Resources1.Designer.cs renamed to Src/BridgeVs.AsyncVsPackage/Configuration/Resources1.Designer.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Src/BridgeVs.VsPackage/Guids.cs renamed to Src/BridgeVs.AsyncVsPackage/Guids.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
using System;
2727

28-
namespace BridgeVs.VsPackage
28+
namespace BridgeVs.VisualStudio.AsyncExtension
2929
{
3030
public static class GuidList
3131
{

0 commit comments

Comments
 (0)