GetAssemblyInfoFileName() public method

public GetAssemblyInfoFileName ( string projectFile ) : string
projectFile string
return string
        public void GetAssemblyInfoFileName_Should_Return_Correct_Result()
        {
            // Arrange:
            var helper = new ProjectPathHelper(Mock.Of<IFileSystem>());

            // Act:
            var result = helper.GetAssemblyInfoFileName("|Dev|SomeProject|ProjectFile.csproj".Path());

            // Assert:
            Assert.AreEqual("|Dev|SomeProject|Properties|AssemblyInfo.cs".Path(), result);
        }
Exemplo n.º 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.");
        }