private void StampProjectWithSDKVersion(ProjectContext project) { if (File.Exists(DotnetFiles.VersionFile)) { var projectVersionFile = project.GetSDKVersionFile(_args.ConfigValue, _args.BuildBasePathValue, _args.OutputValue); var parentDirectory = Path.GetDirectoryName(projectVersionFile); if (!Directory.Exists(parentDirectory)) { Directory.CreateDirectory(parentDirectory); } string content = DotnetFiles.ReadAndInterpretVersionFile(); File.WriteAllText(projectVersionFile, content); } else { Reporter.Verbose.WriteLine($"Project {project.GetDisplayName()} was not stamped with a CLI version because the version file does not exist: {DotnetFiles.VersionFile}"); } }
private bool CLIChangedSinceLastCompilation(ProjectContext project) { var currentVersionFile = DotnetFiles.VersionFile; var versionFileFromLastCompile = project.GetSDKVersionFile(_args.ConfigValue, _args.BuildBasePathValue, _args.OutputValue); if (!File.Exists(currentVersionFile)) { // this CLI does not have a version file; cannot tell if CLI changed return false; } if (!File.Exists(versionFileFromLastCompile)) { // this is the first compilation; cannot tell if CLI changed return false; } var versionsAreEqual = string.Equals(File.ReadAllText(currentVersionFile), File.ReadAllText(versionFileFromLastCompile), StringComparison.OrdinalIgnoreCase); return !versionsAreEqual; }