Пример #1
0
        private static bool VersionNewer(VersionStamp thisVersion, VersionStamp thatVersion)
        {
            var version = thisVersion.GetNewerVersion(thatVersion);

            if (version == thisVersion)
            {
                return(true);
            }
            return(false);
        }
Пример #2
0
        public override async Task <IList <CSharpAssembly> > Parse(string artefact, CancellationToken token)
        {
            var result = new List <CSharpAssembly>();

            var workspace = MSBuildWorkspace.Create(new Dictionary <string, string>
            {
                { "Configuration", settingsProvider.Configuration },
                { "Platform", settingsProvider.Platform }
            });

            var solution = await workspace.OpenSolutionAsync(artefact, token);

            foreach (var project in solution.Projects)
            {
                if (!File.Exists(project.OutputFilePath))
                {
                    throw new ArgumentException($"The assembly {project.OutputFilePath} for project {project.Name} does not exist!" +
                                                $"\nCheck the configuration and platform configured in the app settings (Configuration: {settingsProvider.Configuration}, Platform: {settingsProvider.Platform}).");
                }

                VersionStamp latestDocumentVersion = await project.GetLatestDocumentVersionAsync(token);

                var assemblyCreationTime = File.GetLastWriteTimeUtc(project.OutputFilePath);

                var assemblyVersionStamp = VersionStamp.Create(assemblyCreationTime);

                var newerTimeStamp = latestDocumentVersion.GetNewerVersion(assemblyVersionStamp);
                if (newerTimeStamp != assemblyVersionStamp)
                {
                    throw new ArgumentException($"The assembly {project.OutputFilePath} for project {project.Name} is not up-to-date, please compile the project first!");
                }

                token.ThrowIfCancellationRequested();
                result.Add(new CSharpAssembly {
                    AbsolutePath = project.OutputFilePath
                });
            }

            return(result);
        }
Пример #3
0
 private static bool VersionNewer(VersionStamp thisVersion, VersionStamp thatVersion)
 {
     var version = thisVersion.GetNewerVersion(thatVersion);
     if (version == thisVersion) return true;
     return false;
 }