Skip to content

Commit

Permalink
Changed: upgraded libraries.
Browse files Browse the repository at this point in the history
Fixed: assembly version WF upgrade error.
Fixed: new connection referencing old one until relaunch.
  • Loading branch information
yagasoft committed Jan 27, 2024
1 parent 1192d50 commit 78743a0
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 37 deletions.
15 changes: 10 additions & 5 deletions CrmCodeGenerator.VSPackage/CrmPluginRegExt.VSPackage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@
<HintPath>..\packages\Microsoft.Win32.Registry.5.0.0\lib\net461\Microsoft.Win32.Registry.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xrm.Client, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Yagasoft.Libraries.EnhancedOrgService.6.2.1\lib\net462\Microsoft.Xrm.Client.dll</HintPath>
<HintPath>..\packages\Yagasoft.Libraries.EnhancedOrgService.7.1.1\lib\net462\Microsoft.Xrm.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CrmSdk.CoreAssemblies.9.0.2.21\lib\net462\Microsoft.Xrm.Sdk.dll</HintPath>
Expand Down Expand Up @@ -587,6 +587,11 @@
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
Expand Down Expand Up @@ -652,11 +657,11 @@
<Reference Include="Xceed.Wpf.Toolkit">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.8\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
</Reference>
<Reference Include="Yagasoft.Libraries.Common, Version=3.3.3.0, Culture=neutral, PublicKeyToken=d99f90f6e31ed2df, processorArchitecture=MSIL">
<HintPath>..\packages\Yagasoft.Libraries.Common.4.1.4\lib\net462\Yagasoft.Libraries.Common.dll</HintPath>
<Reference Include="Yagasoft.Libraries.Common, Version=8.1.1.1, Culture=neutral, PublicKeyToken=d99f90f6e31ed2df, processorArchitecture=MSIL">
<HintPath>..\packages\Yagasoft.Libraries.Common.8.1.1\lib\net462\Yagasoft.Libraries.Common.dll</HintPath>
</Reference>
<Reference Include="Yagasoft.Libraries.EnhancedOrgService, Version=6.2.1.0, Culture=neutral, PublicKeyToken=d99f90f6e31ed2df, processorArchitecture=MSIL">
<HintPath>..\packages\Yagasoft.Libraries.EnhancedOrgService.6.2.1\lib\net462\Yagasoft.Libraries.EnhancedOrgService.dll</HintPath>
<Reference Include="Yagasoft.Libraries.EnhancedOrgService, Version=7.1.1.1, Culture=neutral, PublicKeyToken=d99f90f6e31ed2df, processorArchitecture=MSIL">
<HintPath>..\packages\Yagasoft.Libraries.EnhancedOrgService.7.1.1\lib\net462\Yagasoft.Libraries.EnhancedOrgService.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
20 changes: 19 additions & 1 deletion CrmCodeGenerator.VSPackage/Dialogs/Login.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public partial class Login : INotifyPropertyChanged
{
#region Properties

private const string WindowTitle = "Plugin Registration Extension v4.1.1";
private const string WindowTitle = "Plugin Registration Extension v4.1.2";

private readonly ConnectionManager connectionManager;
private DefaultPluginRegLogger registrationLog;
Expand Down Expand Up @@ -309,6 +309,24 @@ private void Cancel_Click(object sender, RoutedEventArgs e)

private void RegisterEvents()
{
settings.PropertyChanged +=
(o, args) =>
{
try
{
switch (args.PropertyName)
{
case nameof(settings.ConnectionString):
connectionManager.ConnectionString = settings.ConnectionString;
break;
}
}
catch
{
// ignored
}
};

assemblyRegistration.PropertyChanged +=
(o, args) =>
{
Expand Down
8 changes: 4 additions & 4 deletions CrmCodeGenerator.VSPackage/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ahmed Elsawalhy (yagasoft.com)")]
[assembly: AssemblyProduct("CrmPluginRegExt.VSPackage")]
[assembly: AssemblyCopyright("Yagasoft 2023")]
[assembly: AssemblyCopyright("Copyright © Ahmed Elsawalhy")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
Expand All @@ -30,8 +30,8 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("4.1.1.0")]
[assembly: AssemblyFileVersion("4.1.1.0")]
[assembly: AssemblyVersion("4.1.2.0")]
[assembly: AssemblyFileVersion("4.1.2.0")]


[assembly: ProvideBindingRedirection(AssemblyName = "Microsoft.Xrm.Sdk",
Expand Down Expand Up @@ -60,4 +60,4 @@

[assembly: ProvideBindingRedirection(AssemblyName = "Yagasoft.Libraries.Common",
CodeBase = @"$PackageFolder$\Yagasoft.Libraries.Common.dll",
OldVersionLowerBound = "0.0.0.0", OldVersionUpperBound = "3.0.0.0")]
OldVersionLowerBound = "0.0.0.0", OldVersionUpperBound = "8.0.0.0")]
5 changes: 3 additions & 2 deletions CrmCodeGenerator.VSPackage/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
<package id="System.Threading.AccessControl" version="5.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Dataflow" version="5.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.3.0" targetFramework="net472" />
<package id="VSLangProj" version="17.0.31902.203" targetFramework="net472" />
<package id="VSLangProj100" version="17.0.31902.203" targetFramework="net472" />
<package id="VSLangProj110" version="17.0.31902.203" targetFramework="net472" />
Expand All @@ -140,6 +141,6 @@
<package id="VSLangProj80" version="17.0.31902.203" targetFramework="net472" />
<package id="VSLangProj90" version="17.0.31902.203" targetFramework="net472" />
<package id="WindowsAzure.ServiceBus" version="3.3.2" targetFramework="net472" />
<package id="Yagasoft.Libraries.Common" version="4.1.4" targetFramework="net472" developmentDependency="true" />
<package id="Yagasoft.Libraries.EnhancedOrgService" version="6.2.1" targetFramework="net472" developmentDependency="true" />
<package id="Yagasoft.Libraries.Common" version="8.1.1" targetFramework="net472" developmentDependency="true" />
<package id="Yagasoft.Libraries.EnhancedOrgService" version="7.1.1" targetFramework="net472" developmentDependency="true" />
</packages>
2 changes: 1 addition & 1 deletion CrmCodeGenerator.VSPackage/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="CrmPluginRegExt" Version="4.1.1" Language="en-US" Publisher="Ahmed Elsawalhy (Yagasoft.com)" />
<Identity Id="CrmPluginRegExt" Version="4.1.2" Language="en-US" Publisher="Ahmed Elsawalhy (Yagasoft.com)" />
<DisplayName>Dynamics CRM - Plugin Registration Extension</DisplayName>
<Description xml:space="preserve">Visual Studio extension that reduces the hassle of using the official plugin tool, so it is much easier and faster to update plugins.</Description>
<MoreInfo>https://marketplace.visualstudio.com/items?itemName=Yagasoft.CrmPluginRegExt</MoreInfo>
Expand Down
37 changes: 21 additions & 16 deletions Yagasoft.CrmPluginRegistration/AssemblyRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using CrmPluginEntities;
using CrmPluginRegExt.AssemblyInfoLoader;
Expand Down Expand Up @@ -345,7 +346,7 @@ private bool UpgradeAssembly(byte[] assemblyData, ref bool? sandbox)
{
var existingAssemblies = CrmAssemblyHelpers.GetCrmAssembly(assemblyName, connectionManager, log);

var oldestAssembly = existingAssemblies.FirstOrDefault();
var oldestAssembly = existingAssemblies.OrderByDescending(a => a.Version).FirstOrDefault();
var oldestVersion = oldestAssembly?.Version.IsFilled() == true ? new Version(oldestAssembly.Version) : null;
UpdateStatus($"Existing version: v{oldestVersion} ... ");

Expand Down Expand Up @@ -392,7 +393,7 @@ private bool UpgradeAssembly(byte[] assemblyData, ref bool? sandbox)
.GetCrmSteps(connectionManager, log, oldestAssembly.Id);
UpdateStatus($"Found: {existingSteps.Count}.");

var existingAssemblyFullName = $"{oldestAssembly.Name}, Version={oldestAssembly.Version},"
var existingAssemblyFullName = $"{oldestAssembly.Name}, Version=.*?,"
+ $" Culture={oldestAssembly.Culture}, PublicKeyToken={oldestAssembly.PublicKeyToken}";

var existingWfs = RetrieveExistingWfs(existingAssemblyFullName);
Expand Down Expand Up @@ -521,20 +522,19 @@ private bool UpgradeWfDefinitions(string existingAssemblyFullName, IReadOnlyList
{
UpdateStatus($"Deactivating WFs ... ");

Parallel.ForEach(activeWfs, new ParallelOptions { MaxDegreeOfParallelism = activeWfs.Length },
wf =>
{
var service = connectionManager.Get();
foreach (var wf in activeWfs)
{
var service = connectionManager.Get();

UpdateStatus($"Deactivating WF: {wf.Name} ({wf.Id}) ... ");
service.Update(
new Workflow
{
Id = wf.Id,
StateCode = WorkflowState.Draft,
StatusCode = Workflow.Enums.StatusCode.Draft.ToOptionSetValue()
});
});
UpdateStatus($"Deactivating WF: {wf.Name} ({wf.Id}) ... ");
service.Update(
new Workflow
{
Id = wf.Id,
StateCode = WorkflowState.Draft,
StatusCode = Workflow.Enums.StatusCode.Draft.ToOptionSetValue()
});
}
}
else
{
Expand All @@ -553,7 +553,7 @@ private bool UpgradeWfDefinitions(string existingAssemblyFullName, IReadOnlyList
new Workflow
{
Id = wf.Id,
Xaml = wf.Xaml.Replace(existingAssemblyFullName, newAssemblyFullName)
Xaml = Regex.Replace(wf.Xaml, existingAssemblyFullName, newAssemblyFullName)
});
});

Expand Down Expand Up @@ -934,6 +934,9 @@ private void DeleteTree(Guid objectId, Dependency.Enums.RequiredComponentType ty
case Dependency.Enums.RequiredComponentType.SDKMessageProcessingStep:
logicalname = SdkMessageProcessingStep.EntityLogicalName;
break;
case Dependency.Enums.RequiredComponentType.Workflow:
logicalname = SdkMessageProcessingStep.EntityLogicalName;
break;
case Dependency.Enums.RequiredComponentType.SDKMessageProcessingStepImage:
dependencies.Clear();
logicalname = SdkMessageProcessingStepImage.EntityLogicalName;
Expand Down Expand Up @@ -992,6 +995,8 @@ private IReadOnlyList<Workflow> RetrieveExistingWfs(string existingAssemblyFullN

using var xrmContext = new XrmServiceContext(connectionManager.Get()) { MergeOption = MergeOption.NoTracking };

existingAssemblyFullName = existingAssemblyFullName.Split(',').FirstOrDefault();

var existingWfs =
(from wf in xrmContext.WorkflowSet
where wf.Xaml.Contains(existingAssemblyFullName)
Expand Down
10 changes: 5 additions & 5 deletions Yagasoft.CrmPluginRegistration/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[assembly: AssemblyTitle("Yagasoft.CrmPluginRegistration")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Yagasoft.CrmPluginRegistration")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyCompany("Ahmed Elsawalhy (yagasoft.com)")]
[assembly: AssemblyProduct("CrmPluginRegExt.VSPackage")]
[assembly: AssemblyCopyright("Copyright © Ahmed Elsawalhy")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// 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")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
<Reference Include="System.Security" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Workflow.Activities" />
<Reference Include="System.Workflow.ComponentModel" />
Expand All @@ -77,8 +80,8 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Yagasoft.Libraries.Common, Version=3.3.3.0, Culture=neutral, PublicKeyToken=d99f90f6e31ed2df, processorArchitecture=MSIL">
<HintPath>..\packages\Yagasoft.Libraries.Common.4.1.1\lib\net462\Yagasoft.Libraries.Common.dll</HintPath>
<Reference Include="Yagasoft.Libraries.Common, Version=8.1.1.1, Culture=neutral, PublicKeyToken=d99f90f6e31ed2df, processorArchitecture=MSIL">
<HintPath>..\packages\Yagasoft.Libraries.Common.8.1.1\lib\net462\Yagasoft.Libraries.Common.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Yagasoft.CrmPluginRegistration/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<package id="Microsoft.CrmSdk.CoreAssemblies" version="9.0.2.25" targetFramework="net462" />
<package id="Microsoft.CrmSdk.Workflow" version="9.0.2.25" targetFramework="net462" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net462" />
<package id="Yagasoft.Libraries.Common" version="4.1.1" targetFramework="net462" developmentDependency="true" />
<package id="System.ValueTuple" version="4.3.0" targetFramework="net462" />
<package id="Yagasoft.Libraries.Common" version="8.1.1" targetFramework="net462" developmentDependency="true" />
</packages>

0 comments on commit 78743a0

Please sign in to comment.