Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm using uSync along with Umbraco 7 and I have a class library that contains some migration code (using the migration system of Umbraco). The first version is supposed to create content, however, I cannot do so until uSync has run.
I searched how to run the import with code and I saw that it's possible with uSync.BackOffice. However, I cannot really install this package in my class library as it will install Umbraco as well...
I tried with uSync.Core but with no luck. How could I run a full import from a class library?
Because both you uSync and your migration run from ApplicationEventHandlers there is no way of specifying their run order.
So it could be that usync runs first, but it also could be that your migrations run first.
What we did once is run uSync from our migration that depends on it.
This is the code we have in the project. It's a few years old so things might have changed :
// Make sure that uSync has run before moving content so all properties exist.
var uSyncBackOffice = Jumoo.uSync.BackOffice.uSyncBackOfficeContext.Instance;
var settings = uSyncBackOffice.Configuration.Settings;
Excuse me but did you read my original question ? That’s exactly what I want to do but as I said I can’t because I’m in a class library where I can’t install uSync.BackOffice...
Why can't you install uSync in the class library ?
Because it depends on uSync that depends on Umbraco, so the whole Umbraco web site ends up in the class library when the goal is specifically to keep the site appart from the this project
Ha..i see some comments in our code about that.
We just referenced the uSync dll
And from git log I see after the migration had run on all servers we removed the reference and commented the migration code.
I’m sorry but I don’t see what I can do with your answer :-D
Sorry just trying to help out !
Instead of installing usync into your class library using nuget, you should reference the uSync dlls in your class libray (from the packages folder where nuget installs them).
Than you can use the code snippet I posted before in your migration.
If you don't want to keep the reference in your project you can delete it after the migration has run on all your servers. And ofcourse comment the code I just posted.
You'll think I'm picky but I really like code separation. For now, I have a project "MyProject" that contains the Umbraco site. Views and Macro are the only custom elements that I have in this project. This way, when I update the Umbraco NuGet package, I really have few risk of collisions or issues.
Then I have a class library "MyProject.Core" that is reference by "MyProject". This project also uses "UmbracoCms.Core" to "talk" with Umbraco and that's really nice. I want the reference to be unidirectional. Meaning that I'm okay with "MyProject" referencing "MyProject.Core" but not the other way around. I understand that you're not saying to reference "MyProject" from "MyProject.Core" but rather a DLL of "MyProject" but still, I don't like the idea (even though it's not a bad one) :-$
That's why I thought that it's awesome that uSync came with "uSync.Core". In my mind, it was the same purpose of "UmbracoCms.Core", but apparently, not exactly...
So basically, you're saying that I can't do exactly what I want?
You probably have installed uSync using nuget,
So that means the dll's are also availabe in the nuget "packages" folder. So you can reference it from there. No need to reference it from your website bin folder.
We use the same approach in set up by the way. So it isn't the most clean way, but a very pratical and temporary solution,
Yep, in the "packages" folder of "MyProject" project (I didn't install the packages at solution level).
But anyway, I see your point. I guess that's how I'll do if there is not a cleaner way :-)
Package developers (me included) should have better separation between "Web" and "Core".
I'm planning to do this for new packages.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted