Skip to content

Commit

Permalink
Move BizTalkAssemblyResolver into Be.Stateless.BizTalk.Explorer
Browse files Browse the repository at this point in the history
Expose BizTalkInstallation helper class
Bump up BizTalk.Server.2020.* NuGets
  • Loading branch information
François Chabot authored and icraftsoftware committed Jun 12, 2021
1 parent 7f3fe78 commit 533348a
Show file tree
Hide file tree
Showing 11 changed files with 349 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .build
2 changes: 1 addition & 1 deletion .settings
Submodule .settings updated 1 files
+244 −0 TextEditor.vssettings
1 change: 1 addition & 0 deletions Be.Stateless.BizTalk.Explorer.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<s:Double x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=FileAD76E8C2C25CED47A6FA160551990498/RelativePriority/@EntryValue">4</s:Double>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Chabot/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Fran_00E7ois/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mgmt/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=MSBTS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unenlist/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unenlisted/@EntryIndexedValue">True</s:Boolean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BizTalk.Server.2020.Runtime" Version="1.0.0">
<PackageReference Include="BizTalk.Server.2020.Runtime" Version="1.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BizTalk.Server.2020.Utilities" Version="1.0.0">
<PackageReference Include="BizTalk.Server.2020.Utilities" Version="1.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -21,7 +21,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit.core" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#region Copyright & License

// Copyright © 2012 - 2021 François Chabot
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#endregion

using System;
using Be.Stateless.BizTalk.Explorer;
using FluentAssertions;
using Xunit;

namespace Be.Stateless.BizTalk.Management
{
public class BizTalkInstallationFixture
{
[Fact]
public void DeveloperToolsPath()
{
BizTalkInstallation.DeveloperToolsPath.Should().Be($@"{INSTALLATION_PATH}\Developer Tools\");
}

[Fact]
public void InstallationPath()
{
BizTalkInstallation.InstallationPath.Should().Be($@"{INSTALLATION_PATH}\");
}

[Fact]
public void IsInstalled()
{
BizTalkInstallation.IsInstalled.Should().BeTrue();
}

[SkippableFact]
public void ManagementDatabaseName()
{
Skip.IfNot(BizTalkServerGroup.IsConfigured);
BizTalkInstallation.ManagementDatabaseName.Should().Be("BizTalkMgmtDb");
}

[SkippableFact]
public void ManagementDatabaseServer()
{
Skip.IfNot(BizTalkServerGroup.IsConfigured);
BizTalkInstallation.ManagementDatabaseServer.Should().Be(Environment.MachineName);
}

[Fact]
public void PipelineToolsPath()
{
BizTalkInstallation.PipelineToolsPath.Should().Be($@"{INSTALLATION_PATH}\SDK\Utilities\PipelineTools\");
}

[SkippableFact]
public void SqlScriptsPath()
{
Skip.IfNot(BizTalkServerGroup.IsConfigured);
BizTalkInstallation.SqlScriptsPath.Should().Be($@"{INSTALLATION_PATH}\Schema\");
}

private const string INSTALLATION_PATH = @"C:\Program Files (x86)\Microsoft BizTalk Server";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@

<ItemGroup>
<PackageReference Include="Be.Stateless.Extensions" Version="2.0.21005.38790" />
<PackageReference Include="BizTalk.Server.2020.Runtime" Version="1.0.0">
<PackageReference Include="BizTalk.Server.2020.Runtime" Version="1.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BizTalk.Server.2020.Utilities" Version="1.0.0">
<PackageReference Include="BizTalk.Server.2020.Utilities" Version="1.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
16 changes: 5 additions & 11 deletions src/Be.Stateless.BizTalk.Explorer/Explorer/BizTalkServerGroup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Copyright & License

// Copyright © 2012 - 2020 François Chabot
// Copyright © 2012 - 2021 François Chabot
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@

#endregion

using Microsoft.Win32;
using Be.Stateless.BizTalk.Management;

namespace Be.Stateless.BizTalk.Explorer
{
Expand All @@ -28,22 +28,16 @@ public static class BizTalkServerGroup
static BizTalkServerGroup()
{
Applications = new ApplicationCollection();
const string path = @"SOFTWARE\Microsoft\BizTalk Server\3.0\Administration";
using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
using (var subKey = baseKey.OpenSubKey(path))
{
ManagementDatabase = subKey != null
? new BizTalkServerManagementDatabase((string) subKey.GetValue("MgmtDBServer"), (string) subKey.GetValue("MgmtDBName"))
: null;
}
if (BizTalkInstallation.IsConfigured)
ManagementDatabase = new BizTalkServerManagementDatabase(BizTalkInstallation.ManagementDatabaseServer, BizTalkInstallation.ManagementDatabaseName);
}

/// <summary>
/// The collection of applications installed on the local BizTalk Server Group.
/// </summary>
public static ApplicationCollection Applications { get; }

public static bool IsConfigured => ManagementDatabase != null;
public static bool IsConfigured => BizTalkInstallation.IsConfigured;

public static BizTalkServerManagementDatabase ManagementDatabase { get; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#region Copyright & License

// Copyright © 2012 - 2021 François Chabot
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#endregion

using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.CompilerServices;
using Microsoft.Win32;

namespace Be.Stateless.BizTalk.Management
{
public static class BizTalkInstallation
{
[SuppressMessage("ReSharper", "InvertIf")]
static BizTalkInstallation()
{
using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
using (var btsKey = baseKey.OpenSubKey(@"SOFTWARE\Microsoft\BizTalk Server\3.0"))
{
if (btsKey?.GetValue("InstallPath") is string installPath)
{
IsInstalled = true;
_installationPath = installPath;
_pipelineToolsPath = Path.Combine(installPath, @"SDK\Utilities\PipelineTools\");
using (var administrationKey = btsKey.OpenSubKey("Administration"))
{
_managementDatabaseName = (string) administrationKey?.GetValue("MgmtDBName");
_managementDatabaseServer = (string) administrationKey?.GetValue("MgmtDBServer");
_sqlScriptsPath = (string) administrationKey?.GetValue("SQLScriptPath");
}
// see Microsoft.BizTalk.Studio.Extensibility.ProjectSystemHelper, Microsoft.BizTalk.Studio.Extensibility, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
using (var xmlToolsKey = btsKey.OpenSubKey("XML TOOLS"))
{
_developerToolsPath = (string) xmlToolsKey?.GetValue("DataFilesPath");
}
}
}
}

public static string DeveloperToolsPath => _developerToolsPath ?? ThrowInstallationException();

public static string InstallationPath => _installationPath ?? ThrowInstallationException();

internal static bool IsConfigured => IsInstalled && _managementDatabaseName != null && _managementDatabaseServer != null;

public static bool IsInstalled { get; }

public static string ManagementDatabaseName => _managementDatabaseName ?? ThrowInstallationException();

public static string ManagementDatabaseServer => _managementDatabaseServer ?? ThrowInstallationException();

public static string PipelineToolsPath => _pipelineToolsPath ?? ThrowInstallationException();

[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Public API.")]
public static string SqlScriptsPath => _sqlScriptsPath ?? ThrowInstallationException();

private static string ThrowInstallationException([CallerMemberName] string name = null)
{
if (!IsInstalled) throw new InvalidOperationException("BizTalk Server is not installed.");
throw new InvalidOperationException($"BizTalk Server installation is incomplete; {name} could not be determined.");
}

private static readonly string _developerToolsPath;
private static readonly string _installationPath;
private static readonly string _managementDatabaseName;
private static readonly string _managementDatabaseServer;
private static readonly string _pipelineToolsPath;
private static readonly string _sqlScriptsPath;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#region Copyright & License

// Copyright © 2012 - 2020 François Chabot
// Copyright © 2012 - 2021 François Chabot
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -71,7 +71,6 @@ public OrchestrationStatus Status
}

[SuppressMessage("ReSharper", "UseStringInterpolation")]
[SuppressMessage("Globalization", "CA1305:Specify IFormatProvider")]
private ManagementPath ManagementPath
{
get
Expand Down Expand Up @@ -256,8 +255,6 @@ private void WmiRefresh()
private static readonly ILog _logger = LogManager.GetLogger(typeof(Orchestration));
private readonly Type _orchestrationType;
private bool _isDisposed;

[SuppressMessage("Usage", "CA2213:Disposable fields should be disposed")]
private ManagementObject _managementObject;
}
}

0 comments on commit 533348a

Please sign in to comment.