配置 Unicorn 的序列化位置,以便将项目添加到 Visual Studio 解决方案

Configure serialization location of Unicorn so the item are added to Visual Studio solution

我想让 Sitecore 的所有项目在 Visual Studio 解决方案中得到序列化。

我知道可以配置成绝对路径。但是团队中的每个团队成员都有不同的VS解决路径。

我还计划在构建服务器中自动执行将序列化项目添加到数据库的过程。如果有人可以提供如何操作的说明,那就太好了。 Jenkins 用于构建。

在 Unicorn 2 配置文件中,app_Config\include\Serialization.config 您找到了路径选项。如果您在同一目录中有 Sitecore 网站和 VS 解决方案(这不是 Sitecore 的建议),那么 Web 根目录相对路径就可以工作。否则每个团队成员都需要使用相同的路径结构。

<!-- 
Note the Serialization Provider's rootPath can be any of:
Absolute filesystem path, e.g. c:\foo\bar
Web-root-relative path, e.g. ~/data/serialization or ~/../out-of-root-serialization
"default", e.g. standard Sitecore serialization path
-->
                <serializationProvider type="Unicorn.Serialization.Sitecore.Fiat.FiatSitecoreSerializationProvider, Unicorn" rootPath="~/../../Serialization" singleInstance="true" />

您不必将序列化文件添加到您的解决方案中,只需将它们添加到您的版本系统中即可。

部署有 2 个选项。

1) 使用 Sitecore Courier 创建一个包,并使用 Sitecore.Ship 或脚本文件。 https://github.com/jbluemink/Sitecore-Scripted-Upgrade-Migrate-Content/tree/master/stap1 or this https://github.com/HedgehogDevelopment/UpdatePackageInstaller

2) 使用 Unicorn 同步,只需点击 URL 查看文档。 https://github.com/kamsar/Unicorn

发布项目使用 https://marketplace.sitecore.net/Modules/Parameter_driven_publish_deployment_tool.aspx

这就是我们最终实现的。

  1. 所有团队成员使用一个公共位置来存储源代码和序列化内容。
  2. 将独角兽序列化指向第一步文件夹。
  3. 为 jenkins 安装 powershell 插件。
  4. 在 jenkins 中使用以下 powershell 脚本。

    $url = 'http://yoursite/unicorn.aspx?verb=Sync'

    $deploymentToolAuthToken = 'auth-token'

    $result = Invoke-WebRequest -Uri $url -Headers @{ "Authenticate" = $deploymentToolAuthToken } -TimeoutSec 10800 -UseBasicParsing