-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit moving from CodePlex; change license
- Loading branch information
Showing
25 changed files
with
2,033 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" ?> | ||
<!-- | ||
BizTalk ESB Toolkit Enterprise Library machine.config Toggler | ||
Copyright (C) 2013-Present Thomas F. Abraham. All Rights Reserved. | ||
Licensed under the MIT License. See License.txt in the project root. | ||
--> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Main" ToolsVersion="4.0"> | ||
<PropertyGroup> | ||
<Version>1.0.0</Version> | ||
<ZipFile>ESBToolkitEntLibMachineConfigToggler_v$(Version).zip</ZipFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Binaries Include="License.txt" /> | ||
<Binaries Include=".\src\Console\bin\release\ESBToolkitEntLibMachineConfigToggler.exe" /> | ||
<Binaries Include=".\src\UI\bin\release\ESBToolkitEntLibMachineConfigTogglerUI.exe" /> | ||
<Binaries Include=".\src\Common\bin\release\ESBToolkitEntLibMachineConfigToggler.Common.dll" /> | ||
</ItemGroup> | ||
|
||
<Target Name="Main" DependsOnTargets="BuildSolution;PackageBinaries"/> | ||
|
||
<Target Name="BuildSolution"> | ||
<MSBuild Projects="src\ESBToolkitEntLibMachineConfigToggler.sln" Properties="Configuration=Release" Targets="Rebuild" /> | ||
</Target> | ||
|
||
<Target Name="PackageBinaries"> | ||
<Delete Files="Staging\$(ZipFile)" /> | ||
<Exec Command="tools\7za a -r -tzip Staging\$(ZipFile) @(Binaries)" Condition="%(Identity) == %(Identity)" /> | ||
</Target> | ||
</Project> |
56 changes: 56 additions & 0 deletions
56
src/Common/ESBToolkitEntLibMachineConfigToggler.Common.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{41B97CDB-A66F-41D9-93E1-B53AF9EA8244}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>ESBToolkitEntLibMachineConfigToggler.Common</RootNamespace> | ||
<AssemblyName>ESBToolkitEntLibMachineConfigToggler.Common</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<PlatformTarget>x86</PlatformTarget> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="EsbGlobalConfigToggler.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="ToggleStatusEventArgs.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
// BizTalk ESB Toolkit Enterprise Library machine.config Toggler | ||
// Copyright (C) 2013-Present Thomas F. Abraham. All Rights Reserved. | ||
// Licensed under the MIT License. See License.txt in the project root. | ||
|
||
using Microsoft.Win32; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
using System.Xml; | ||
using System.Xml.Linq; | ||
|
||
namespace ESBToolkitEntLibMachineConfigToggler.Common | ||
{ | ||
public class EsbGlobalConfigToggler | ||
{ | ||
const string commentedSectionRegex = @"<!--\s*(<section name=""enterpriseLibrary.ConfigurationSource""[\w,=,"",',,\.,\s]+/>)\s*-->"; | ||
const string commentedSourceRegex = @"<!--\s*(<enterpriseLibrary.ConfigurationSource[\w\W]*</enterpriseLibrary.ConfigurationSource>)\s*-->"; | ||
const string uncommentedSectionRegex = @"(<section name=""enterpriseLibrary.ConfigurationSource""[\w,=,"",',,\.,\s]+/>)"; | ||
const string uncommentedSourceRegex = @"(<enterpriseLibrary.ConfigurationSource[\w\W]*</enterpriseLibrary.ConfigurationSource>)"; | ||
|
||
public event EventHandler<ToggleStatusEventArgs> ToggleMessage; | ||
|
||
public void Toggle() | ||
{ | ||
List<string> machineConfigPaths = GetMachineConfigPaths(); | ||
|
||
foreach (string machineConfigPath in machineConfigPaths) | ||
{ | ||
OnStatusChanged("Processing '" + machineConfigPath + "'..."); | ||
|
||
string xml = File.ReadAllText(machineConfigPath); | ||
|
||
bool foundCommentedSection = false; | ||
bool foundCommentedSource = false; | ||
bool foundUncommented = false; | ||
|
||
Match commentedSectionMatch = Regex.Match(xml, commentedSectionRegex); | ||
|
||
if (commentedSectionMatch.Success) | ||
{ | ||
foundCommentedSection = true; | ||
} | ||
|
||
Match commentedSourceMatch = Regex.Match(xml, commentedSourceRegex); | ||
|
||
if (commentedSourceMatch.Success) | ||
{ | ||
foundCommentedSource = true; | ||
} | ||
|
||
if (foundCommentedSection && !foundCommentedSource) | ||
{ | ||
xml = Regex.Replace(xml, commentedSectionRegex, commentedSectionMatch.Groups[1].Value); | ||
OnStatusChanged("Found commented section and uncommented enterpriseLibrary.ConfigurationSource. Enabling..."); | ||
} | ||
else if (!foundCommentedSection && foundCommentedSource) | ||
{ | ||
xml = Regex.Replace(xml, commentedSourceRegex, commentedSourceMatch.Groups[1].Value); | ||
OnStatusChanged("Found uncommented section and commented enterpriseLibrary.ConfigurationSource. Enabling..."); | ||
} | ||
else if (foundCommentedSection && foundCommentedSource) | ||
{ | ||
xml = Regex.Replace(xml, commentedSectionRegex, commentedSectionMatch.Groups[1].Value); | ||
xml = Regex.Replace(xml, commentedSourceRegex, commentedSourceMatch.Groups[1].Value); | ||
OnStatusChanged("Found commented section and commented enterpriseLibrary.ConfigurationSource. Enabling..."); | ||
} | ||
else | ||
{ | ||
Match uncommentedSectionMatch = Regex.Match(xml, uncommentedSectionRegex); | ||
|
||
if (uncommentedSectionMatch.Success) | ||
{ | ||
foundUncommented = true; | ||
xml = Regex.Replace(xml, uncommentedSectionRegex, "<!--" + uncommentedSectionMatch.Groups[1].Value + "-->"); | ||
} | ||
|
||
Match uncommentedSourceMatch = Regex.Match(xml, uncommentedSourceRegex); | ||
|
||
if (uncommentedSourceMatch.Success) | ||
{ | ||
foundUncommented = true; | ||
xml = Regex.Replace(xml, uncommentedSourceRegex, "<!--" + uncommentedSourceMatch.Groups[1].Value + "-->"); | ||
} | ||
|
||
if (foundUncommented) | ||
{ | ||
OnStatusChanged("Found uncommented section and uncommented enterpriseLibrary.ConfigurationSource. Disabling..."); | ||
} | ||
else | ||
{ | ||
OnStatusChanged("No changes required because no enterpriseLibrary.ConfigurationSource was found."); | ||
} | ||
} | ||
|
||
if (foundCommentedSection || foundCommentedSource || foundUncommented) | ||
{ | ||
string machineConfigBackupPath = machineConfigPath + ".esbtoggle.bak"; | ||
if (File.Exists(machineConfigBackupPath)) | ||
{ | ||
File.Delete(machineConfigBackupPath); | ||
} | ||
File.Copy(machineConfigPath, machineConfigBackupPath, true); | ||
|
||
OnStatusChanged("Saved machine.config changes."); | ||
File.WriteAllText(machineConfigPath, xml); | ||
} | ||
|
||
OnStatusChanged(string.Empty); | ||
} | ||
} | ||
|
||
private List<string> GetMachineConfigPaths() | ||
{ | ||
List<string> paths = new List<string>(); | ||
|
||
paths.AddRange( | ||
GetMachineConfigPathsForVersion( | ||
@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full", | ||
"InstallPath", | ||
@"config\machine.config")); | ||
|
||
paths.AddRange( | ||
GetMachineConfigPathsForVersion( | ||
@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework", | ||
"InstallRoot", | ||
@"v2.0.50727\config\machine.config")); | ||
|
||
return paths; | ||
} | ||
|
||
private List<string> GetMachineConfigPathsForVersion(string regPath, string regKey, string machineConfigSubPath) | ||
{ | ||
List<string> paths = new List<string>(); | ||
|
||
bool isWin64 = Directory.Exists(Path.Combine(Environment.GetEnvironmentVariable("windir"), "syswow64")); | ||
|
||
string netInstallPath = Registry.GetValue(regPath, regKey, null) as string; | ||
|
||
if (!string.IsNullOrEmpty(netInstallPath)) | ||
{ | ||
string netMachineConfigPath = Path.Combine(netInstallPath, machineConfigSubPath); | ||
|
||
paths.Add(netMachineConfigPath); | ||
|
||
if (isWin64) | ||
{ | ||
netMachineConfigPath = netMachineConfigPath.Replace(@"Framework\", @"Framework64\"); | ||
paths.Add(netMachineConfigPath); | ||
} | ||
} | ||
|
||
return paths; | ||
} | ||
|
||
private void OnStatusChanged(string message) | ||
{ | ||
if (ToggleMessage != null) | ||
{ | ||
ToggleMessage(this, new ToggleStatusEventArgs(message)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// BizTalk ESB Toolkit Enterprise Library machine.config Toggler | ||
// Copyright (C) 2013-Present Thomas F. Abraham. All Rights Reserved. | ||
// Licensed under the MIT License. See License.txt in the project root. | ||
|
||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("ESBToolkitEntLibMachineConfigToggler.Common")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Thomas F. Abraham")] | ||
[assembly: AssemblyProduct("ESBToolkitEntLibMachineConfigToggler.Common")] | ||
[assembly: AssemblyCopyright("Copyright © Thomas F. Abraham 2013")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("debc0d21-a1bf-4c00-ad79-add3643c4943")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// BizTalk ESB Toolkit Enterprise Library machine.config Toggler | ||
// Copyright (C) 2013-Present Thomas F. Abraham. All Rights Reserved. | ||
// Licensed under the MIT License. See License.txt in the project root. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace ESBToolkitEntLibMachineConfigToggler.Common | ||
{ | ||
public class ToggleStatusEventArgs : EventArgs | ||
{ | ||
public string Message { get; private set; } | ||
|
||
internal ToggleStatusEventArgs(string message) | ||
{ | ||
this.Message = message; | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/Console/ESBToolkitEntLibMachineConfigToggler.Console.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{91C8D7ED-3D8E-4A65-A9EE-5041F97F741E}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>ESBToolkitEntLibMachineConfigToggler.Console</RootNamespace> | ||
<AssemblyName>ESBToolkitEntLibMachineConfigToggler</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<ApplicationManifest>app.manifest</ApplicationManifest> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Common\ESBToolkitEntLibMachineConfigToggler.Common.csproj"> | ||
<Project>{41b97cdb-a66f-41d9-93e1-b53af9ea8244}</Project> | ||
<Name>ESBToolkitEntLibMachineConfigToggler.Common</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.manifest" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
Oops, something went wrong.