Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Msbuild 使用CCNetLabel使用CruiseControl.NET设置AssemblyVersion和PublishVersion_Msbuild_Clickonce_Cruisecontrol.net - Fatal编程技术网

Msbuild 使用CCNetLabel使用CruiseControl.NET设置AssemblyVersion和PublishVersion

Msbuild 使用CCNetLabel使用CruiseControl.NET设置AssemblyVersion和PublishVersion,msbuild,clickonce,cruisecontrol.net,Msbuild,Clickonce,Cruisecontrol.net,我正在尝试使用CruiseControl.NET部署一次点击应用程序(构建和发布)。我无法找到在哪里可以使用CCNetLabel设置我的AssemblyVersion和/或PublishVersion。我会接受其他解决方案,这些解决方案允许每个CruiseControl.NET部署(实时部署和开发部署)具有唯一的版本号。您需要编写脚本来设置AssemblyVersion。我建议为此使用NAnt或MSBuild,但PowerShell或简单的bat文件也可以 在您的CCNET配置中使用。然后,可以

我正在尝试使用CruiseControl.NET部署一次点击应用程序(构建和发布)。我无法找到在哪里可以使用CCNetLabel设置我的AssemblyVersion和/或PublishVersion。我会接受其他解决方案,这些解决方案允许每个CruiseControl.NET部署(实时部署和开发部署)具有唯一的版本号。

您需要编写脚本来设置AssemblyVersion。我建议为此使用NAnt或MSBuild,但PowerShell或简单的bat文件也可以

在您的CCNET配置中使用。然后,可以通过
${CCNetLabel}
(NAnt)resp在脚本内部使用CCNetLabel。环境变量
%CCNetLabel%
(批处理-尝试不同的外壳,因为我知道它们有问题)

该脚本的任务是编辑项目的AssemblyInfo.cs文件或创建CommonAssemblyInfo.cs文件,并从项目中引用该文件进行生成

所以寻找

[cruisecontrol.net]程序集信息


产生更有价值的建议。

正如另一位回答者指出的那样,您需要在AssemblyInfo.cs中编译之前设置它。Labeller的汇编版本很棒,但它不能与svn一起使用。如果您使用svn,您可能需要查看


正确生成标签后,可以在创建/编辑AssemblyInfo.cs文件时在CC或Nant脚本中使用该标签。如果您正在使用Nant,那么asminfo任务将对您有很大帮助。SO搜索会很好,但您可能还想看一看,这应该非常有帮助。

您可以通过一个南音C#snipped来实现这一点

创建名为${assemblyinfo.file}的属性,该属性指向项目中的assemblyinfo.cs文件

    <!-- Updating assembly version with the CI build http://lazyloading.blogspot.com/2007/05/updating-assembly-version-with-ci.html -->
<target name="update.assembly" description="Replaces the version in the assemblyinfo.cs file">
    <echo message="AssemblyInfo: ${assemblyinfo.file}" />
    <echo message="Version: ${CCNetLabel}" />
    <script language="C#">
        <references>
            <include name="System.dll" />
        </references>
        <imports>
            <import namespace="System.Text.RegularExpressions" />
        </imports>
        <code>
        <![CDATA[
            public static void ScriptMain(Project project)
            {
                string fileContent="";
                using (StreamReader reader = new StreamReader(project.Properties["assemblyinfo.file"]))
                {
                    fileContent = reader.ReadToEnd();
                    reader.Close();
                }
                string newVersion = string.Format("[assembly: AssemblyVersion(\"{0}\")]", project.Properties["CCNetLabel"]);
                string newText = Regex.Replace(fileContent, @"\[assembly: AssemblyVersion\("".*""\)\]", newVersion);
                using (StreamWriter writer = new StreamWriter(project.Properties["assemblyinfo.file"], false))
                {
                    writer.Write(newText);
                    writer.Close();
                }
            }
        ]]>
        </code>
    </script>
</target>


例如:

[汇编:汇编版本(“1.0.*)]

变成

[组装:组装版本(“2013.03.11.001”)]


程序集版本labeller的答案中的链接已断开,但您可以找到它的cruisecontrol.net文档