Merge pull request #573 from KindDragon/checkintool
Assemblies loading for Policy Evaluator and Checkintool improved
This commit is contained in:
@@ -48,6 +48,8 @@ namespace Sep.Git.Tfs.Vs2008
|
||||
return VersionControl.AuthenticatedUser;
|
||||
}
|
||||
|
||||
public void SetPathResolver() { }
|
||||
|
||||
public override bool CanShowCheckinDialog
|
||||
{
|
||||
get { return false; }
|
||||
|
||||
@@ -71,51 +71,16 @@ namespace Sep.Git.Tfs.Vs2010
|
||||
return VersionControl.AuthorizedUser;
|
||||
}
|
||||
|
||||
public override bool CanShowCheckinDialog { get { return true; } }
|
||||
private string vsInstallDir;
|
||||
|
||||
public override long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable<IWorkItemCheckedInfo> checkedInfos, string checkinComment)
|
||||
protected override string GetVsInstallDir()
|
||||
{
|
||||
return ShowCheckinDialog(_bridge.Unwrap<Workspace>(workspace),
|
||||
pendingChanges.Select(p => _bridge.Unwrap<PendingChange>(p)).ToArray(),
|
||||
checkedInfos.Select(c => _bridge.Unwrap<WorkItemCheckedInfo>(c)).ToArray(),
|
||||
checkinComment);
|
||||
}
|
||||
|
||||
private long ShowCheckinDialog(Workspace workspace, PendingChange[] pendingChanges,
|
||||
WorkItemCheckedInfo[] checkedInfos, string checkinComment)
|
||||
{
|
||||
using (var parentForm = new ParentForm())
|
||||
if (vsInstallDir == null)
|
||||
{
|
||||
parentForm.Show();
|
||||
|
||||
var dialog = Activator.CreateInstance(GetCheckinDialogType(), new object[] {workspace.VersionControlServer});
|
||||
|
||||
return dialog.Call<int>("Show", parentForm.Handle, workspace, pendingChanges, pendingChanges,
|
||||
checkinComment, null, null, checkedInfos);
|
||||
vsInstallDir = TryGetRegString(@"Software\Microsoft\VisualStudio\10.0", "InstallDir")
|
||||
?? TryGetRegString(@"Software\WOW6432Node\Microsoft\VisualStudio\10.0", "InstallDir");
|
||||
}
|
||||
}
|
||||
|
||||
private const string DialogAssemblyName = "Microsoft.TeamFoundation.VersionControl.ControlAdapter";
|
||||
|
||||
private static Type GetCheckinDialogType()
|
||||
{
|
||||
return GetDialogAssembly().GetType(DialogAssemblyName + ".CheckinDialog");
|
||||
}
|
||||
|
||||
private static Assembly GetDialogAssembly()
|
||||
{
|
||||
return Assembly.LoadFrom(GetDialogAssemblyPath());
|
||||
}
|
||||
|
||||
private static string GetDialogAssemblyPath()
|
||||
{
|
||||
return Path.Combine(GetVs2010InstallDir(), "PrivateAssemblies", DialogAssemblyName + ".dll");
|
||||
}
|
||||
|
||||
private static string GetVs2010InstallDir()
|
||||
{
|
||||
return TryGetRegString(@"Software\Microsoft\VisualStudio\10.0", "InstallDir")
|
||||
?? TryGetRegString(@"Software\WOW6432Node\Microsoft\VisualStudio\10.0", "InstallDir");
|
||||
return vsInstallDir;
|
||||
}
|
||||
|
||||
private static string TryGetRegString(string path, string name)
|
||||
|
||||
@@ -10,12 +10,18 @@ namespace Sep.Git.Tfs.Vs2012
|
||||
{
|
||||
}
|
||||
|
||||
private string vsInstallDir;
|
||||
|
||||
protected override string GetVsInstallDir()
|
||||
{
|
||||
return TryGetRegString(@"Software\Microsoft\VisualStudio\11.0", "InstallDir")
|
||||
?? TryGetRegString(@"Software\WOW6432Node\Microsoft\VisualStudio\11.0", "InstallDir")
|
||||
?? TryGetUserRegString(@"Software\Microsoft\WDExpress\11.0_Config", "InstallDir")
|
||||
?? TryGetUserRegString(@"Software\WOW6432Node\Microsoft\WDExpress\11.0_Config", "InstallDir");
|
||||
if (vsInstallDir == null)
|
||||
{
|
||||
vsInstallDir = TryGetRegString(@"Software\Microsoft\VisualStudio\11.0", "InstallDir")
|
||||
?? TryGetRegString(@"Software\WOW6432Node\Microsoft\VisualStudio\11.0", "InstallDir")
|
||||
?? TryGetUserRegString(@"Software\Microsoft\WDExpress\11.0_Config", "InstallDir")
|
||||
?? TryGetUserRegString(@"Software\WOW6432Node\Microsoft\WDExpress\11.0_Config", "InstallDir");
|
||||
}
|
||||
return vsInstallDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,18 @@ namespace Sep.Git.Tfs.Vs2013
|
||||
{
|
||||
}
|
||||
|
||||
private string vsInstallDir;
|
||||
|
||||
protected override string GetVsInstallDir()
|
||||
{
|
||||
return TryGetRegString(@"Software\Microsoft\VisualStudio\12.0", "InstallDir")
|
||||
if (vsInstallDir == null)
|
||||
{
|
||||
vsInstallDir = TryGetRegString(@"Software\Microsoft\VisualStudio\12.0", "InstallDir")
|
||||
?? TryGetRegString(@"Software\WOW6432Node\Microsoft\VisualStudio\12.0", "InstallDir")
|
||||
?? TryGetUserRegString(@"Software\Microsoft\WDExpress\12.0_Config", "InstallDir")
|
||||
?? TryGetUserRegString(@"Software\WOW6432Node\Microsoft\WDExpress\12.0_Config", "InstallDir");
|
||||
}
|
||||
return vsInstallDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ using Sep.Git.Tfs.Core.TfsInterop;
|
||||
using Sep.Git.Tfs.Util;
|
||||
using StructureMap;
|
||||
using StructureMap.Attributes;
|
||||
using ChangeType = Microsoft.TeamFoundation.Server.ChangeType;
|
||||
|
||||
namespace Sep.Git.Tfs.VsCommon
|
||||
{
|
||||
|
||||
@@ -3,11 +3,14 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.TeamFoundation.Client;
|
||||
using Microsoft.TeamFoundation.VersionControl.Client;
|
||||
using Sep.Git.Tfs.Core;
|
||||
using Sep.Git.Tfs.Core.TfsInterop;
|
||||
using Sep.Git.Tfs.Util;
|
||||
using StructureMap;
|
||||
using ChangeType = Microsoft.TeamFoundation.VersionControl.Client.ChangeType;
|
||||
|
||||
namespace Sep.Git.Tfs.VsCommon
|
||||
{
|
||||
@@ -15,11 +18,17 @@ namespace Sep.Git.Tfs.VsCommon
|
||||
{
|
||||
TfsApiBridge _bridge;
|
||||
protected TfsTeamProjectCollection _server;
|
||||
private static bool _resolverInstalled;
|
||||
|
||||
public TfsHelperVs2010Base(TextWriter stdout, TfsApiBridge bridge, IContainer container)
|
||||
: base(stdout, bridge, container)
|
||||
{
|
||||
_bridge = bridge;
|
||||
if (!_resolverInstalled)
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve += LoadFromVsFolder;
|
||||
_resolverInstalled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanGetBranchInformation
|
||||
@@ -214,6 +223,64 @@ namespace Sep.Git.Tfs.VsCommon
|
||||
{
|
||||
VersionControl.CreateBranchObject(new BranchProperties(new ItemIdentifier(tfsRepositoryPath)));
|
||||
}
|
||||
|
||||
protected abstract string GetVsInstallDir();
|
||||
|
||||
/// <summary>
|
||||
/// Help the TFS client find checkin policy assemblies.
|
||||
/// </summary>
|
||||
Assembly LoadFromVsFolder(object sender, ResolveEventArgs args)
|
||||
{
|
||||
Trace.WriteLine("Looking for assembly " + args.Name + " ...");
|
||||
string folderPath = Path.Combine(GetVsInstallDir(), "PrivateAssemblies");
|
||||
string assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll");
|
||||
if (File.Exists(assemblyPath) == false)
|
||||
return null;
|
||||
Trace.WriteLine("... loading " + args.Name + " from " + assemblyPath);
|
||||
Assembly assembly = Assembly.LoadFrom(assemblyPath);
|
||||
return assembly;
|
||||
}
|
||||
|
||||
public override bool CanShowCheckinDialog { get { return true; } }
|
||||
|
||||
public override long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable<IWorkItemCheckedInfo> checkedInfos, string checkinComment)
|
||||
{
|
||||
return ShowCheckinDialog(_bridge.Unwrap<Workspace>(workspace),
|
||||
pendingChanges.Select(p => _bridge.Unwrap<PendingChange>(p)).ToArray(),
|
||||
checkedInfos.Select(c => _bridge.Unwrap<WorkItemCheckedInfo>(c)).ToArray(),
|
||||
checkinComment);
|
||||
}
|
||||
|
||||
private long ShowCheckinDialog(Workspace workspace, PendingChange[] pendingChanges,
|
||||
WorkItemCheckedInfo[] checkedInfos, string checkinComment)
|
||||
{
|
||||
using (var parentForm = new ParentForm())
|
||||
{
|
||||
parentForm.Show();
|
||||
|
||||
var dialog = Activator.CreateInstance(GetCheckinDialogType(), new object[] { workspace.VersionControlServer });
|
||||
|
||||
return dialog.Call<int>("Show", parentForm.Handle, workspace, pendingChanges, pendingChanges,
|
||||
checkinComment, null, null, checkedInfos);
|
||||
}
|
||||
}
|
||||
|
||||
private const string DialogAssemblyName = "Microsoft.TeamFoundation.VersionControl.ControlAdapter";
|
||||
|
||||
private Type GetCheckinDialogType()
|
||||
{
|
||||
return GetDialogAssembly().GetType(DialogAssemblyName + ".CheckinDialog");
|
||||
}
|
||||
|
||||
private Assembly GetDialogAssembly()
|
||||
{
|
||||
return Assembly.LoadFrom(GetDialogAssemblyPath());
|
||||
}
|
||||
|
||||
private string GetDialogAssemblyPath()
|
||||
{
|
||||
return Path.Combine(GetVsInstallDir(), "PrivateAssemblies", DialogAssemblyName + ".dll");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,49 +76,6 @@ namespace Sep.Git.Tfs.VsCommon
|
||||
return Retry.Do(() => changeset.AssociatedWorkItems.Length > 0);
|
||||
}
|
||||
|
||||
public override bool CanShowCheckinDialog { get { return true; } }
|
||||
|
||||
public override long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable<IWorkItemCheckedInfo> checkedInfos, string checkinComment)
|
||||
{
|
||||
return ShowCheckinDialog(_bridge.Unwrap<Workspace>(workspace),
|
||||
pendingChanges.Select(p => _bridge.Unwrap<PendingChange>(p)).ToArray(),
|
||||
checkedInfos.Select(c => _bridge.Unwrap<WorkItemCheckedInfo>(c)).ToArray(),
|
||||
checkinComment);
|
||||
}
|
||||
|
||||
private long ShowCheckinDialog(Workspace workspace, PendingChange[] pendingChanges,
|
||||
WorkItemCheckedInfo[] checkedInfos, string checkinComment)
|
||||
{
|
||||
using (var parentForm = new ParentForm())
|
||||
{
|
||||
parentForm.Show();
|
||||
|
||||
var dialog = Activator.CreateInstance(GetCheckinDialogType(), new object[] {workspace.VersionControlServer});
|
||||
|
||||
return dialog.Call<int>("Show", parentForm.Handle, workspace, pendingChanges, pendingChanges,
|
||||
checkinComment, null, null, checkedInfos);
|
||||
}
|
||||
}
|
||||
|
||||
private const string DialogAssemblyName = "Microsoft.TeamFoundation.VersionControl.ControlAdapter";
|
||||
|
||||
private Type GetCheckinDialogType()
|
||||
{
|
||||
return GetDialogAssembly().GetType(DialogAssemblyName + ".CheckinDialog");
|
||||
}
|
||||
|
||||
private Assembly GetDialogAssembly()
|
||||
{
|
||||
return Assembly.LoadFrom(GetDialogAssemblyPath());
|
||||
}
|
||||
|
||||
private string GetDialogAssemblyPath()
|
||||
{
|
||||
return Path.Combine(GetVsInstallDir(), "PrivateAssemblies", DialogAssemblyName + ".dll");
|
||||
}
|
||||
|
||||
protected abstract string GetVsInstallDir();
|
||||
|
||||
protected string TryGetUserRegString(string path, string name)
|
||||
{
|
||||
return TryGetRegString(Registry.CurrentUser, path, name);
|
||||
|
||||
@@ -45,6 +45,8 @@ namespace Sep.Git.Tfs.VsFake
|
||||
|
||||
public void EnsureAuthenticated() {}
|
||||
|
||||
public void SetPathResolver() {}
|
||||
|
||||
public bool CanShowCheckinDialog { get { return false; } }
|
||||
|
||||
public long ShowCheckinDialog(IWorkspace workspace, IPendingChange[] pendingChanges, IEnumerable<IWorkItemCheckedInfo> checkedInfos, string checkinComment)
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Sep.Git.Tfs.Core
|
||||
|
||||
var newChangesetId = _tfsHelper.ShowCheckinDialog(_workspace, pendingChanges, GetWorkItemCheckedInfos(), checkinComment);
|
||||
if (newChangesetId <= 0)
|
||||
throw new GitTfsException("Checkin cancelled!");
|
||||
throw new GitTfsException("Checkin canceled!");
|
||||
return newChangesetId;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,9 @@
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NDesk.Options, Version=0.2.1.0, Culture=neutral">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
@@ -255,6 +258,7 @@
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="App.config" />
|
||||
<None Include="app.manifest" />
|
||||
<None Include="Core\TfsInterop\README.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
</asmv1:assembly>
|
||||
Reference in New Issue
Block a user