ReplaceAssemblyAttribute() публичный Метод

public ReplaceAssemblyAttribute ( string code, Type attributeType ) : string
code string
attributeType System.Type
Результат string
 public void ReplaceAssemblyAttribute_Should_Correctly_Replace_The_Existing_Attribute()
 {
     var modifier = new AssemblyInfoModifier();
     var result = modifier.ReplaceAssemblyAttribute(TestData.AssemblyInfoContent_WebApi, typeof(AssemblyVersionAttribute), "2.0.0.0");
     Assert.AreEqual(1, Regex.Matches(result, "AssemblyVersion").Count);
 }
Пример #2
0
        private void SetVersionForProject(string projectPath, Version defaultVersion, string additionalInfo)
        {
            var helper = new ProjectPathHelper(this.fileSystem);

            this.output.WriteLine("Processing project '{0}'...", projectPath);

            this.output.WriteLine("-> Reading version...");
            Version version;
            if (!helper.TryRetrieveVersion(projectPath, out version))
            {
                version = defaultVersion;
            }

            this.output.WriteLine("-> Reading assembly info...");
            string assemblyInfoFile = helper.GetAssemblyInfoFileName(projectPath);
            string assemblyInfo = this.fileSystem.FileExists(assemblyInfoFile) ? this.fileSystem.ReadAllText(assemblyInfoFile) : string.Empty;

            this.output.WriteLine("-> AddingReplacing version information...");
            var modifier = new AssemblyInfoModifier();
            assemblyInfo = modifier.ReplaceAssemblyAttribute(assemblyInfo, typeof(AssemblyVersionAttribute), version.ToString());
            assemblyInfo = modifier.ReplaceAssemblyAttribute(assemblyInfo, typeof(AssemblyFileVersionAttribute), version.ToString());

            if (additionalInfo != null)
            {
                this.output.WriteLine("-> Adding/Replacing additional information...");
                assemblyInfo = modifier.ReplaceAssemblyAttribute(assemblyInfo, typeof(AssemblyInformationalVersionAttribute), additionalInfo);
            }

            this.output.WriteLine("-> Saving assembly info...");
            this.fileSystem.WriteAllText(assemblyInfoFile, assemblyInfo);

            this.output.WriteLine("Processing project finished.");
        }