コード例 #1
0
        void CreateTempAssemblyInfo(VersionVariables versionVariables)
        {
            if (IntermediateOutputPath == null)
            {
                var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());
                AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
            }
            else
            {
                AssemblyInfoTempFilePath = Path.Combine(IntermediateOutputPath, "GitVersionTaskAssemblyInfo.g.cs");
            }

            var assemblyInfoBuilder = new AssemblyInfoBuilder();
            var assemblyInfo        = assemblyInfoBuilder.GetAssemblyInfoText(versionVariables, RootNamespace).Trim();

            // We need to try to read the existing text first if the file exists and see if it's the same
            // This is to avoid writing when there's no differences and causing a rebuild
            try
            {
                if (File.Exists(AssemblyInfoTempFilePath))
                {
                    var content = File.ReadAllText(AssemblyInfoTempFilePath, Encoding.UTF8).Trim();
                    if (string.Equals(assemblyInfo, content, StringComparison.Ordinal))
                    {
                        return; // nothign to do as the file matches what we'd create
                    }
                }
            }
            catch (Exception)
            {
                // Something happened reading the file, try to overwrite anyway
            }

            File.WriteAllText(AssemblyInfoTempFilePath, assemblyInfo, Encoding.UTF8);
        }
コード例 #2
0
        void CreateTempAssemblyInfo(VersionAndBranchAndDate versionAndBranch)
        {
            var assemblyInfoBuilder = new AssemblyInfoBuilder
            {
                VersionAndBranch = versionAndBranch,
                SignAssembly     = SignAssembly
            };
            var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText();

            var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());

            AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
            File.WriteAllText(AssemblyInfoTempFilePath, assemblyInfo);
        }
コード例 #3
0
        void CreateTempAssemblyInfo(SemanticVersion semanticVersion, AssemblyVersioningScheme avs)
        {
            var assemblyInfoBuilder = new AssemblyInfoBuilder
            {
                SemanticVersion          = semanticVersion,
                AssemblyVersioningScheme = avs,
                AppendRevision           = AppendRevision
            };
            var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText();

            var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());

            AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
            File.WriteAllText(AssemblyInfoTempFilePath, assemblyInfo);
        }
コード例 #4
0
        void CreateTempAssemblyInfo(VersionVariables versionVariables)
        {
            if (IntermediateOutputPath == null)
            {
                var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());
                AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
            }
            else
            {
                AssemblyInfoTempFilePath = Path.Combine(IntermediateOutputPath, "GitVersionTaskAssemblyInfo.g.cs");
            }

            var assemblyInfoBuilder = new AssemblyInfoBuilder();
            var assemblyInfo        = assemblyInfoBuilder.GetAssemblyInfoText(versionVariables, RootNamespace);

            File.WriteAllText(AssemblyInfoTempFilePath, assemblyInfo);
        }
コード例 #5
0
        void CreateTempAssemblyInfo(CachedVersion semanticVersion, EffectiveConfiguration configuration)
        {
            if (IntermediateOutputPath == null)
            {
                var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());
                AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
            }
            else
            {
                AssemblyInfoTempFilePath = Path.Combine(IntermediateOutputPath, "GitVersionTaskAssemblyInfo.g.cs");
            }

            var assemblyInfoBuilder = new AssemblyInfoBuilder
            {
                CachedVersion = semanticVersion
            };
            var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText(configuration);

            File.WriteAllText(AssemblyInfoTempFilePath, assemblyInfo);
        }
コード例 #6
0
        void CreateTempAssemblyInfo(SemanticVersion semanticVersion, AssemblyVersioningScheme avs)
        {
            var assemblyInfoBuilder = new AssemblyInfoBuilder
                                      {
                                          SemanticVersion = semanticVersion,
                                          AssemblyVersioningScheme = avs,
                                          AppendRevision = AppendRevision
                                      };
            var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText();

            var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());
            AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
            File.WriteAllText(AssemblyInfoTempFilePath, assemblyInfo);
        }
コード例 #7
0
        void CreateTempAssemblyInfo(VersionVariables versionVariables)
        {
            if (IntermediateOutputPath == null)
            {
                var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());
                AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
            }
            else
            {
                AssemblyInfoTempFilePath = Path.Combine(IntermediateOutputPath, "GitVersionTaskAssemblyInfo.g.cs");
            }

            var assemblyInfoBuilder = new AssemblyInfoBuilder();
            var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText(versionVariables, RootNamespace).Trim();

            // We need to try to read the existing text first if the file exists and see if it's the same
            // This is to avoid writing when there's no differences and causing a rebuild
            try
            {
                if (File.Exists(AssemblyInfoTempFilePath))
                {
                    var content = File.ReadAllText(AssemblyInfoTempFilePath, Encoding.UTF8).Trim();
                    if (string.Equals(assemblyInfo, content, StringComparison.Ordinal))
                    {
                        return; // nothign to do as the file matches what we'd create
                    }
                }
            }
            catch (Exception)
            {
                // Something happened reading the file, try to overwrite anyway
            }

            File.WriteAllText(AssemblyInfoTempFilePath, assemblyInfo, Encoding.UTF8);
        }
コード例 #8
0
        void CreateTempAssemblyInfo(VersionVariables versionVariables)
        {
            if (IntermediateOutputPath == null)
            {
                var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());
                AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
            }
            else
            {
                AssemblyInfoTempFilePath = Path.Combine(IntermediateOutputPath, "GitVersionTaskAssemblyInfo.g.cs");
            }

            var assemblyName = Path.GetFileNameWithoutExtension(ProjectFile);
            var startsWithNumbers = new Regex(@"^\d+");
            if (startsWithNumbers.IsMatch(assemblyName))
            {
                assemblyName = startsWithNumbers.Replace(assemblyName, string.Empty);
            }

            var assemblyInfoBuilder = new AssemblyInfoBuilder();
            var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText(versionVariables, assemblyName);
            File.WriteAllText(AssemblyInfoTempFilePath, assemblyInfo);
        }
コード例 #9
0
        void CreateTempAssemblyInfo(VersionVariables versionVariables)
        {
            if (IntermediateOutputPath == null)
            {
                var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());
                AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
            }
            else
            {
                AssemblyInfoTempFilePath = Path.Combine(IntermediateOutputPath, "GitVersionTaskAssemblyInfo.g.cs");
            }

            var assemblyInfoBuilder = new AssemblyInfoBuilder();
            var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText(versionVariables, RootNamespace);
            File.WriteAllText(AssemblyInfoTempFilePath, assemblyInfo);
        }
コード例 #10
0
        void CreateTempAssemblyInfo(CachedVersion semanticVersion, EffectiveConfiguration configuration)
        {
            if (IntermediateOutputPath == null)
            {
                var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName());
                AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName);
            }
            else
            {
                AssemblyInfoTempFilePath = Path.Combine(IntermediateOutputPath, "GitVersionTaskAssemblyInfo.g.cs");
            }

            var assemblyInfoBuilder = new AssemblyInfoBuilder
            {
                CachedVersion = semanticVersion
            };
            var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText(configuration);
            File.WriteAllText(AssemblyInfoTempFilePath, assemblyInfo);
        }