“AssemblyInfoFileMask'未声明。它可能无法访问由于其保护级别 [英] 'AssemblyInfoFileMask' is not declared. It may be inaccessible due to its protection level

查看:526
本文介绍了“AssemblyInfoFileMask'未声明。它可能无法访问由于其保护级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个自定义生成TFS活动,蔚蓝的不断整合内部使用。

我用从这个博客code:
<一href=\"http://www.ewaldhofman.nl/post/2010/06/01/Customize-Team-Build-2010-e28093-Part-10-Include-Version-Number-in-the-Build-Number.aspx\" rel=\"nofollow\">http://www.ewaldhofman.nl/post/2010/06/01/Customize-Team-Build-2010-e28093-Part-10-Include-Version-Number-in-the-Build-Number.aspx

你可以在公共低于code看到AssemblyInfoFileMask。
也请检查的截图,看看我的意思,BuildDetail其在同一类和犯规给我的蓝色图标错误。

我将它粘贴在这里code,以及:

  [BuildActivity(HostEnvironmentOption.Controller)
    公共密封类GetAssemblyVersion:codeActivity&LT;串GT;
    {
        [RequiredArgument]
        公共InArgument&LT;串GT; AssemblyInfoFileMask {搞定;组; }        [RequiredArgument]
        公共InArgument&LT; IBuildDetail&GT; BuildDetail {搞定;组; }        保护覆盖字符串执行(codeActivityContext上下文)
        {
            //获取的输入参数运行时值
            字符串assemblyInfoFileMask = context.GetValue(this.AssemblyInfoFileMask);
            IBuildDetail buildDetail = context.GetValue(this.BuildDetail);            VAR工作区= buildDetail.BuildDefinition.Workspace;
            VAR VC = buildDetail.BuildServer.TeamProjectCollection.GetService&LT; VersionControlServer&GT;();            字符串属性=的AssemblyFileVersion;            //定义正前pression发现(这是例如'的AssemblyFileVersion(1.0.0.0)')
            正则表达式的regex ​​=新的正则表达式(属性+ @\\(\\ D + \\ \\ D + \\ \\ D + \\ \\ D +,\\)。);            //对于每一个工作区文件夹(映射)
            的foreach(在workspace.Mappings VAR文件夹中)
            {
                //获取所有文件(递归),适用于文件掩码
                套装套装= vc.GetItems(folder.ServerItem +//+ assemblyInfoFileMask,RecursionType.Full);
                的foreach(在itemSet.Items项项)
                {
                    context.TrackBuildMessage(的String.Format(下载{0},item.ServerItem));                    //下载文件
                    字符串LOCALFILE = Path.GetTempFileName();
                    item.DownloadFile(LOCALFILE);                    //读取从程序集信息文件中的文本
                    字符串文本= File.ReadAllText(LOCALFILE);
                    //搜索版本属性的第一次出现
                    匹配匹配= regex.Match(文本);
                    //当发现
                    如果(match.Success)
                    {
                        //检索的版本号
                        字符串的versionNumber = match.Value.Substring(attribute.Length + 2,match.Value.Length - attribute.Length - 4);
                        版本版本=新版本(的versionNumber);
                        //增加集结号 - GT&;这将是在构建新的版本号
                        版本NEWVERSION =新版本(version.Major,version.Minor,version.Build + 1,version.Revision);                        context.TrackBuildMessage(的String.Format(版本发现{0},静态网页));                        返回newVersion.ToString();
                    }
                }
            }            返回找不到版本;
        }
    }
}


解决方案

蓝色感叹号意味着你试图通过一个变量 / <$ C $的价值C>参数名为 AssemblyInfoFileMask 属性您的活动名为 AssemblyInfoFileMask

您需要声明一个参数或可变自己传递给你的活动。

如果您希望能够将 AssemblyInfoFileMask 在构建定义,那么你需要声明它作为一个参数。

请参阅您的图像此更新版本,您将看到您声明它:

一旦你声明的说法,你需要找到元数据采集参数,并将其添加有太多。见<一href=\"http://ericphan.net/blog/2011/5/31/adding-configurable-parameters-to-a-custom-tfs-2010-build-te.html\"相对=nofollow>这个帖子了解更多详情。

如果您不需要设置它在构建定义(这将是恒定的所有版本),然后只需添加一个变量并设置它的值您需要的模式。

I am creating a custom build tfs activity to be used inside the azure continuous integration.

I have used the code from this blog: http://www.ewaldhofman.nl/post/2010/06/01/Customize-Team-Build-2010-e28093-Part-10-Include-Version-Number-in-the-Build-Number.aspx

As you can see AssemblyInfoFileMask in the code below its public. Also please check the screenshot to see what I meant, BuildDetail its on the same class and doesnt show me the error in the blue icon.

I will paste it here the code as well:

[BuildActivity(HostEnvironmentOption.Controller)]
    public sealed class GetAssemblyVersion : CodeActivity<string>
    {
        [RequiredArgument]
        public InArgument<string> AssemblyInfoFileMask { get; set; }

        [RequiredArgument]
        public InArgument<IBuildDetail> BuildDetail { get; set; }

        protected override string Execute(CodeActivityContext context)
        {
            // Obtain the runtime value of the input arguments
            string assemblyInfoFileMask = context.GetValue(this.AssemblyInfoFileMask);
            IBuildDetail buildDetail = context.GetValue(this.BuildDetail);

            var workspace = buildDetail.BuildDefinition.Workspace;
            var vc = buildDetail.BuildServer.TeamProjectCollection.GetService<VersionControlServer>();

            string attribute = "AssemblyFileVersion";

            // Define the regular expression to find (which is for example 'AssemblyFileVersion("1.0.0.0")' )
            Regex regex = new Regex(attribute + @"\(""\d+\.\d+\.\d+\.\d+""\)");

            // For every workspace folder (mapping)
            foreach (var folder in workspace.Mappings)
            {
                // Get all files (recursively) that apply to the file mask
                ItemSet itemSet = vc.GetItems(folder.ServerItem + "//" + assemblyInfoFileMask, RecursionType.Full);
                foreach (Item item in itemSet.Items)
                {
                    context.TrackBuildMessage(string.Format("Download {0}", item.ServerItem));

                    // Download the file
                    string localFile = Path.GetTempFileName();
                    item.DownloadFile(localFile);

                    // Read the text from the AssemblyInfo file
                    string text = File.ReadAllText(localFile);
                    // Search for the first occurrence of the version attribute
                    Match match = regex.Match(text);
                    // When found
                    if (match.Success)
                    {
                        // Retrieve the version number
                        string versionNumber = match.Value.Substring(attribute.Length + 2, match.Value.Length - attribute.Length - 4);
                        Version version = new Version(versionNumber);
                        // Increase the build number -> this will be the new version number for the build
                        Version newVersion = new Version(version.Major, version.Minor, version.Build + 1, version.Revision);

                        context.TrackBuildMessage(string.Format("Version found {0}", newVersion));

                        return newVersion.ToString();
                    }
                }
            }

            return "No version found";
        }
    }
}

解决方案

The Blue Exclamation mark means you are trying to pass the value of a Variable/Argument called AssemblyInfoFileMask to a Property on your Activity called AssemblyInfoFileMask.

You need to declare an Argument or Variable yourself to pass to your activity.

If you want to be able to set the AssemblyInfoFileMask in your build definitions, then you need to declare it as an Argument.

See this updated version of your image you will see where you declare it:

Once you have declared an Argument, you need to find the MetaData Collection Argument and add it there too. See this post for more details.

If you don't need to set it in a build definition (it's going to be constant for all builds), then just add a Variable and set it's value to the Pattern you require.

这篇关于“AssemblyInfoFileMask'未声明。它可能无法访问由于其保护级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆