本文整理汇总了C#中Microsoft.DotNet.ProjectModel.ProjectContext.GetSDKVersionFile方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectContext.GetSDKVersionFile方法的具体用法?C# ProjectContext.GetSDKVersionFile怎么用?C# ProjectContext.GetSDKVersionFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.DotNet.ProjectModel.ProjectContext
的用法示例。
在下文中一共展示了ProjectContext.GetSDKVersionFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StampProjectWithSDKVersion
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}");
}
}
示例2: CLIChangedSinceLastCompilation
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;
}