如何将SiteCore的序列化树检入TFS

时间:2022-08-31 23:34:28

We're using Sitecore and to share the content between developers we're serialising the content tree to the filesystem then checking this into source control. This worked fine in the last project that used SVN, but this new project is using TFS.

我们正在使用Sitecore并在开发人员之间共享内容,我们将内容树序列化到文件系统,然后将其检入源代码控制。这在上一个使用SVN的项目中运行良好,但这个新项目使用的是TFS。

Unfortunately TFS won't accept paths that have a dollar sign in them, ie

不幸的是,TFS不接受在其中有美元符号的路径,即

\serialization\master\sitecore\templates\Branches\Calendar\Agenda View Settings\$name.item

and this is a very common file name for Sitecore's serialisation structure. Is there any way around this? Can Sitecore be changed to not put the $ in front of the file names or do we have to switch to SVN?

这是Sitecore序列化结构的一个非常常见的文件名。有没有办法解决?可以将Sitecore更改为不将$放在文件名前面,还是我们必须切换到SVN?

3 个解决方案

#1


I did some digging around. It's doable, however not immediately straight forward.

我做了一些挖掘。这是可行的,但不能立即直接前进。

When serializing a tree, Sitecore invokes: Sitecore.Shell.Framework.Commands.Serialization.DumpTreeCommand. This is defined in /App_Config/Commands.config. When de-serializing, the equivalent .LoadTreeCommand is invoked.

序列化树时,Sitecore调用:Sitecore.Shell.Framework.Commands.Serialization.DumpTreeCommand。这在/App_Config/Commands.config中定义。反序列化时,调用等效的.LoadTreeCommand。

What these commands do, is little more than invoking:

这些命令的作用不过是调用:

protected override void Dump(Item item)
{
    Sitecore.Data.Serialization.Manager.DumpTree(item);
}

And unfortunately, to get to the functionality you need to override, it looks like you are going to have to 1) override the command in commands.config, and then create your own Serialization Manager (inheriting from Sitecore's).

不幸的是,为了获得您需要覆盖的功能,看起来您将不得不1)覆盖commands.config中的命令,然后创建自己的序列化管理器(继承自Sitecore)。

I'm not entirely sure how easy this would be, since most of the methods in this class are static members. The method you would need to override/re-implement is this one:

我不完全确定这是多么容易,因为这个类中的大多数方法都是静态成员。您需要覆盖/重新实现的方法是这样的:

public static void DumpItem(string path, Item item)
{
    Assert.ArgumentNotNullOrEmpty(path, "path");
    Assert.ArgumentNotNull(item, "item");
    Directory.CreateDirectory(Path.GetDirectoryName(path));
    using (new SecurityDisabler())
    {
        TextWriter writer = new StreamWriter(File.Create(path));
        try
        {
            ItemSynchronization.WriteItem(item, writer);
        }
        catch
        {
        }
        writer.Close();
    }
}

The filename, as you can see, is based entirely on the Item's path. The assumption is, you could perhaps get away with something like .Replace("$", "!dollartoken!") and implement the reverse in your de-serializer.

您可以看到,文件名完全基于Item的路径。假设是,您可能会使用.Replace(“$”,“!dollartoken!”)之类的东西,并在您的反序列化器中实现反向。

Seems a lot of work though, unfortunately.

不幸的是,看起来很多工作。

#2


Oh, and one more thing.

哦,还有一件事。

http://www.hhogdev.com/products/team-development-for-sitecore.aspx

I've not had the chance to test this tool myself yet, but it looks interesting and could potentially be the answer to your source control challenges.

我自己还没有机会测试这个工具,但它看起来很有趣,可能是你的源代码控制挑战的答案。

#3


Is the workaround suggested here (in the 'Community Content' at the bottom of the page) any use to you?

这里建议的解决方法(在页面底部的“社区内容”中)对您有用吗?

#1


I did some digging around. It's doable, however not immediately straight forward.

我做了一些挖掘。这是可行的,但不能立即直接前进。

When serializing a tree, Sitecore invokes: Sitecore.Shell.Framework.Commands.Serialization.DumpTreeCommand. This is defined in /App_Config/Commands.config. When de-serializing, the equivalent .LoadTreeCommand is invoked.

序列化树时,Sitecore调用:Sitecore.Shell.Framework.Commands.Serialization.DumpTreeCommand。这在/App_Config/Commands.config中定义。反序列化时,调用等效的.LoadTreeCommand。

What these commands do, is little more than invoking:

这些命令的作用不过是调用:

protected override void Dump(Item item)
{
    Sitecore.Data.Serialization.Manager.DumpTree(item);
}

And unfortunately, to get to the functionality you need to override, it looks like you are going to have to 1) override the command in commands.config, and then create your own Serialization Manager (inheriting from Sitecore's).

不幸的是,为了获得您需要覆盖的功能,看起来您将不得不1)覆盖commands.config中的命令,然后创建自己的序列化管理器(继承自Sitecore)。

I'm not entirely sure how easy this would be, since most of the methods in this class are static members. The method you would need to override/re-implement is this one:

我不完全确定这是多么容易,因为这个类中的大多数方法都是静态成员。您需要覆盖/重新实现的方法是这样的:

public static void DumpItem(string path, Item item)
{
    Assert.ArgumentNotNullOrEmpty(path, "path");
    Assert.ArgumentNotNull(item, "item");
    Directory.CreateDirectory(Path.GetDirectoryName(path));
    using (new SecurityDisabler())
    {
        TextWriter writer = new StreamWriter(File.Create(path));
        try
        {
            ItemSynchronization.WriteItem(item, writer);
        }
        catch
        {
        }
        writer.Close();
    }
}

The filename, as you can see, is based entirely on the Item's path. The assumption is, you could perhaps get away with something like .Replace("$", "!dollartoken!") and implement the reverse in your de-serializer.

您可以看到,文件名完全基于Item的路径。假设是,您可能会使用.Replace(“$”,“!dollartoken!”)之类的东西,并在您的反序列化器中实现反向。

Seems a lot of work though, unfortunately.

不幸的是,看起来很多工作。

#2


Oh, and one more thing.

哦,还有一件事。

http://www.hhogdev.com/products/team-development-for-sitecore.aspx

I've not had the chance to test this tool myself yet, but it looks interesting and could potentially be the answer to your source control challenges.

我自己还没有机会测试这个工具,但它看起来很有趣,可能是你的源代码控制挑战的答案。

#3


Is the workaround suggested here (in the 'Community Content' at the bottom of the page) any use to you?

这里建议的解决方法(在页面底部的“社区内容”中)对您有用吗?