Skip to content

Commit

Permalink
working on BIDS Helper for SQL 2017 in VS2015
Browse files Browse the repository at this point in the history
  • Loading branch information
furmangg_cp authored and furmangg_cp committed May 1, 2017
1 parent e74c9c5 commit 310cb79
Show file tree
Hide file tree
Showing 16 changed files with 369 additions and 18 deletions.
Binary file added BidsHelper2016.pkgdef.bak
Binary file not shown.
123 changes: 122 additions & 1 deletion BidsHelperPackage.cs
Expand Up @@ -85,6 +85,7 @@ public BIDSHelperPackage()
/// </summary>
protected override void Initialize()
{
bool bQuitting = false;
base.Initialize();

#if DEBUG
Expand All @@ -105,6 +106,13 @@ protected override void Initialize()

DebuggerService.AdviseDebuggerEvents(this, out debugEventCookie);

if (SwitchVsixManifest())
{
bQuitting = true;
RestartVisualStudio();
return;
}

foreach (Type t in Assembly.GetExecutingAssembly().GetTypes())
{
if (//typeof(IBIDSHelperPlugin).IsAssignableFrom(t.GetType())
Expand Down Expand Up @@ -157,7 +165,120 @@ protected override void Initialize()
}
finally
{
StatusBar.Clear();
if (!bQuitting)
StatusBar.Clear();
}

}

private bool SwitchVsixManifest()
{
#if SQL2017
string sVersion = VersionInfo.SqlServerVersion.ToString();
if (sVersion.StartsWith("13.")) //this DLL is for SQL 2017 but you have SSDT for SQL2016 installed
{
string sFolder = System.IO.Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
string sManifestPath = sFolder + "\\extension.vsixmanifest";
string sBackupManifestPath = sFolder + "\\extension2017.vsixmanifest";
string sOtherManifestPath = sFolder + "\\extension2016.vsixmanifest";

string sPkgdef2017Path = sFolder + "\\BidsHelper2017.pkgdef";
string sPkgdef2017BackupPath = sFolder + "\\BidsHelper2017.pkgdef.bak";
string sPkgdef2016Path = sFolder + "\\BidsHelper2016.pkgdef";
string sPkgdef2016BackupPath = sFolder + "\\BidsHelper2016.pkgdef.bak";

if (System.IO.File.Exists(sOtherManifestPath) && System.IO.File.Exists(sPkgdef2016BackupPath) && System.IO.File.Exists(sPkgdef2017Path))
{
//backup the current SQL2017 manifest
System.IO.File.Copy(sManifestPath, sBackupManifestPath, true);

//copy SQL2016 manifest over the current manifest
System.IO.File.Copy(sOtherManifestPath, sManifestPath, true);

if (System.IO.File.Exists(sPkgdef2016Path))
System.IO.File.Delete(sPkgdef2016BackupPath);
else
System.IO.File.Move(sPkgdef2016BackupPath, sPkgdef2016Path);

if (System.IO.File.Exists(sPkgdef2017BackupPath))
System.IO.File.Delete(sPkgdef2017Path);
else
System.IO.File.Move(sPkgdef2017Path, sPkgdef2017BackupPath);

System.Windows.Forms.MessageBox.Show("You have SSDT for SQL Server " + VersionInfo.SqlServerFriendlyVersion + " installed. Please restart Visual Studio so BIDS Helper can reconfigure itself to work properly with that version of SSDT.", "BIDS Helper");
return true;
}
else
{
throw new Exception("You have SSDT for SQL Server " + VersionInfo.SqlServerFriendlyVersion + " installed but we couldn't find BIDS Helper 2016 files!");
}
}
#elif SQL2016
string sVersion = VersionInfo.SqlServerVersion.ToString();
if (sVersion.StartsWith("14.")) //this DLL is for SQL 2016 but you have SSDT for SQL2017 installed
{
string sFolder = System.IO.Directory.GetParent(System.IO.Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName).FullName;
string sManifestPath = sFolder + "\\extension.vsixmanifest";
string sBackupManifestPath = sFolder + "\\extension2016.vsixmanifest";
string sOtherManifestPath = sFolder + "\\extension2017.vsixmanifest";

string sPkgdef2017Path = sFolder + "\\BidsHelper2017.pkgdef";
string sPkgdef2017BackupPath = sFolder + "\\BidsHelper2017.pkgdef.bak";
string sPkgdef2016Path = sFolder + "\\BidsHelper2016.pkgdef";
string sPkgdef2016BackupPath = sFolder + "\\BidsHelper2016.pkgdef.bak";

if (System.IO.File.Exists(sOtherManifestPath) && System.IO.File.Exists(sPkgdef2017BackupPath) && System.IO.File.Exists(sPkgdef2016Path))
{
//backup the current SQL2016 manifest
System.IO.File.Copy(sManifestPath, sBackupManifestPath, true);

//copy SQL2017 manifest over the current manifest
System.IO.File.Copy(sOtherManifestPath, sManifestPath, true);

if (System.IO.File.Exists(sPkgdef2017Path))
System.IO.File.Delete(sPkgdef2017BackupPath);
else
System.IO.File.Move(sPkgdef2017BackupPath, sPkgdef2017Path);

if (System.IO.File.Exists(sPkgdef2016BackupPath))
System.IO.File.Delete(sPkgdef2016Path);
else
System.IO.File.Move(sPkgdef2016Path, sPkgdef2016BackupPath);

System.Windows.Forms.MessageBox.Show("You have SSDT for SQL Server " + VersionInfo.SqlServerFriendlyVersion + " installed. Please restart Visual Studio so BIDS Helper can reconfigure itself to work properly with that version of SSDT.", "BIDS Helper");
return true;
}
else
{
throw new Exception("You have SSDT for SQL Server " + VersionInfo.SqlServerFriendlyVersion + " installed but we couldn't find BIDS Helper 2017 files!");
}
}
#endif
return false;

}

private void RestartVisualStudio()
{
System.Diagnostics.Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
System.Diagnostics.Process newProcess = new System.Diagnostics.Process();
newProcess.StartInfo = new System.Diagnostics.ProcessStartInfo {
FileName = currentProcess.MainModule.FileName,
ErrorDialog = true,
UseShellExecute = true,
Arguments = DTE2.CommandLineArguments
};
newProcess.Start();

EnvDTE.Command command = DTE2.Commands.Item("File.Exit", -1);

if ((command != null) && command.IsAvailable)
{
DTE2.ExecuteCommand("File.Exit", "");
}
else
{
DTE2.Quit();
}

}
Expand Down
6 changes: 3 additions & 3 deletions Core/Options/BIDSHelperOptionsVersion.cs
Expand Up @@ -13,11 +13,11 @@ namespace BIDSHelper.Core
{
[ClassInterface(ClassInterfaceType.AutoDual)]
[CLSCompliant(false), ComVisible(true)]
//[Guid(BIDSHelperOptionsVersion.OptionsGuidString)]
[Guid(BIDSHelperOptionsVersion.VersionGuidString)]
public class BIDSHelperOptionsVersion: DialogPage
{
// public const string OptionsGuidString = "9EBCE16B-26C2-4A22-A409-9752750A16AE";
public const string VersionGuidString = "9128d0ed-abbe-3002-9aee-4c06babd03ae";

protected override IWin32Window Window
{
get
Expand Down
2 changes: 2 additions & 0 deletions Core/VersionInfo.cs
Expand Up @@ -127,6 +127,8 @@ public static string SqlServerFriendlyVersion
return "2014";
else if (sVersion.StartsWith("13."))
return "2016";
else if (sVersion.StartsWith("14."))
return "2017";
else
return string.Format("(SQL Unknown {0})", sVersion);
}
Expand Down
136 changes: 136 additions & 0 deletions Manifest/SQL2017/VSPackage.resx
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="110" xml:space="preserve">
<value>BIDS Helper 2017 Extension</value>
</data>
<data name="112" xml:space="preserve">
<value>BIDS Helper 2017 Visual Studio Extension v2.0.1 - An add-in to extend SQL Server Data Tools</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="400" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\Resources\BidsHelper.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="deploymdxscript" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\Resources\deploymdxscript.xslt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="HelpAboutText" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\helpabouttext.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>
4 changes: 3 additions & 1 deletion Properties/AssemblyInfo.cs
Expand Up @@ -18,7 +18,9 @@
[assembly: CLSCompliant(false)]
[assembly: NeutralResourcesLanguage("en-US")]

#if SQL2016
#if SQL2017
[assembly: AssemblyTitle("BIDS Helper for SQL Server 2017")]
#elif SQL2016
[assembly: AssemblyTitle("BIDS Helper for SQL Server 2016")]
#elif SQL2014
[assembly: AssemblyTitle("BIDS Helper for SQL Server 2014")]
Expand Down
4 changes: 2 additions & 2 deletions SQL2016_BidsHelper.csproj
Expand Up @@ -49,11 +49,11 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectGuid>{0828F434-598D-4E5B-983A-9FAD3BFDE857}</ProjectGuid>
<ProjectGuid>{4EA3FC6B-F3D9-467E-92EA-68AC4C574CB3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BIDSHelper</RootNamespace>
<AssemblyName>BidsHelper</AssemblyName>
<AssemblyName>BidsHelper2016</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<GeneratePkgDefFile>true</GeneratePkgDefFile>
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
Expand Down
48 changes: 48 additions & 0 deletions SQL2017_BidsHelper.sln
@@ -0,0 +1,48 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQL2017_BidsHelper", "SQL2017_BidsHelper.csproj", "{0828F434-598D-4E5B-983A-9FAD3BFDE857}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQL2016_BidsHelper", "SQL2016_BidsHelper.csproj", "{4EA3FC6B-F3D9-467E-92EA-68AC4C574CB3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0828F434-598D-4E5B-983A-9FAD3BFDE857}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0828F434-598D-4E5B-983A-9FAD3BFDE857}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0828F434-598D-4E5B-983A-9FAD3BFDE857}.Debug|x86.ActiveCfg = Debug|x86
{0828F434-598D-4E5B-983A-9FAD3BFDE857}.Debug|x86.Build.0 = Debug|x86
{0828F434-598D-4E5B-983A-9FAD3BFDE857}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0828F434-598D-4E5B-983A-9FAD3BFDE857}.Release|Any CPU.Build.0 = Release|Any CPU
{0828F434-598D-4E5B-983A-9FAD3BFDE857}.Release|x86.ActiveCfg = Release|x86
{0828F434-598D-4E5B-983A-9FAD3BFDE857}.Release|x86.Build.0 = Release|x86
{4EA3FC6B-F3D9-467E-92EA-68AC4C574CB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4EA3FC6B-F3D9-467E-92EA-68AC4C574CB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4EA3FC6B-F3D9-467E-92EA-68AC4C574CB3}.Debug|x86.ActiveCfg = Debug|x86
{4EA3FC6B-F3D9-467E-92EA-68AC4C574CB3}.Debug|x86.Build.0 = Debug|x86
{4EA3FC6B-F3D9-467E-92EA-68AC4C574CB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4EA3FC6B-F3D9-467E-92EA-68AC4C574CB3}.Release|Any CPU.Build.0 = Release|Any CPU
{4EA3FC6B-F3D9-467E-92EA-68AC4C574CB3}.Release|x86.ActiveCfg = Release|x86
{4EA3FC6B-F3D9-467E-92EA-68AC4C574CB3}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 3
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs01
SccProjectUniqueName0 = SQL2017_BidsHelper.csproj
SccLocalPath0 = .
SccProjectUniqueName1 = SQL2016_BidsHelper.csproj
SccLocalPath1 = .
SccLocalPath2 = .
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion SSAS/DeploymentSettings.cs
Expand Up @@ -92,7 +92,7 @@ public string TargetCubeName
private void SetDefaultTargetServer()
{
Microsoft.Win32.RegistryKey regKey;
#if SQL2016
#if SQL2016 || SQL2017
regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\14.0\Packages\{4a0c6509-bf90-43da-abee-0aba3a8527f1}\Settings\Analysis Services Project");
#elif SQL2014
regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\12.0\Packages\{4a0c6509-bf90-43da-abee-0aba3a8527f1}\Settings\Analysis Services Project");
Expand Down

0 comments on commit 310cb79

Please sign in to comment.