Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/Fallout.Build.Shared/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ namespace Fallout.Common;
[UsedImplicitly]
internal static class Constants
{
internal const string NukeFileName = NukeDirectoryName;
internal const string NukeDirectoryName = ".fallout";
internal const string FalloutFileName = FalloutDirectoryName;
internal const string FalloutDirectoryName = ".fallout";
// Legacy directory name from the pre-Fallout era. Read-only: lets existing
// consumer projects keep building until they migrate (manually or via the
// forthcoming Fallout.Migrate CLI). New setups always use .fallout/.
internal const string LegacyNukeDirectoryName = ".nuke";
internal const string NukeCommonPackageId = "Fallout.Common";
internal const string FalloutCommonPackageId = "Fallout.Common";
internal const string BuildSchemaFileName = "build.schema.json";
internal const string VisualStudioDebugFileName = $"{VisualStudioDebugParameterName}.log";

Expand Down Expand Up @@ -62,28 +62,28 @@ internal static class Constants
internal const string UpstreamNukeRepositoryGit = UpstreamNukeRepository + ".git";

internal static AbsolutePath GlobalTemporaryDirectory => Path.GetTempPath();
internal static AbsolutePath GlobalNukeDirectory => EnvironmentInfo.SpecialFolder(SpecialFolders.UserProfile) / ".fallout";
internal static AbsolutePath GlobalFalloutDirectory => EnvironmentInfo.SpecialFolder(SpecialFolders.UserProfile) / ".fallout";

[CanBeNull]
internal static AbsolutePath TryGetRootDirectoryFrom(AbsolutePath startDirectory, bool includeLegacy = true)
{
var rootDirectory = new DirectoryInfo(startDirectory)
.DescendantsAndSelf(x => x.Parent)
.FirstOrDefault(x => x.GetDirectories(NukeDirectoryName).Any() ||
.FirstOrDefault(x => x.GetDirectories(FalloutDirectoryName).Any() ||
x.GetDirectories(LegacyNukeDirectoryName).Any() ||
includeLegacy && x.GetFiles(NukeFileName).Any())
includeLegacy && x.GetFiles(FalloutFileName).Any())
?.FullName;
return rootDirectory != GlobalNukeDirectory.Parent ? (AbsolutePath) rootDirectory : null;
return rootDirectory != GlobalFalloutDirectory.Parent ? (AbsolutePath) rootDirectory : null;
}

internal static bool IsLegacy(AbsolutePath rootDirectory)
{
return File.Exists(rootDirectory / NukeFileName);
return File.Exists(rootDirectory / FalloutFileName);
}

internal static AbsolutePath GetNukeDirectory(AbsolutePath rootDirectory)
internal static AbsolutePath GetFalloutDirectory(AbsolutePath rootDirectory)
{
var newDir = rootDirectory / NukeDirectoryName;
var newDir = rootDirectory / FalloutDirectoryName;
if (Directory.Exists(newDir))
return newDir;
var legacyDir = rootDirectory / LegacyNukeDirectoryName;
Expand All @@ -93,7 +93,7 @@ internal static AbsolutePath GetNukeDirectory(AbsolutePath rootDirectory)
internal static AbsolutePath GetTemporaryDirectory(AbsolutePath rootDirectory)
{
return !IsLegacy(rootDirectory)
? GetNukeDirectory(rootDirectory) / "temp"
? GetFalloutDirectory(rootDirectory) / "temp"
: rootDirectory / ".tmp";
}

Expand Down Expand Up @@ -122,23 +122,23 @@ public static AbsolutePath GetReSharperSurrogateFile(AbsolutePath rootDirectory)

internal static AbsolutePath GetBuildSchemaFile(AbsolutePath rootDirectory)
{
return GetNukeDirectory(rootDirectory) / BuildSchemaFileName;
return GetFalloutDirectory(rootDirectory) / BuildSchemaFileName;
}

internal static AbsolutePath GetDefaultParametersFile(AbsolutePath rootDirectory)
{
return GetNukeDirectory(rootDirectory) / GetParametersFileName(DefaultProfileName);
return GetFalloutDirectory(rootDirectory) / GetParametersFileName(DefaultProfileName);
}

internal static IEnumerable<AbsolutePath> GetParametersProfileFiles(AbsolutePath rootDirectory)
{
return new DirectoryInfo(GetNukeDirectory(rootDirectory)).GetFiles($"{ParametersFilePrefix}.*.json", SearchOption.TopDirectoryOnly)
return new DirectoryInfo(GetFalloutDirectory(rootDirectory)).GetFiles($"{ParametersFilePrefix}.*.json", SearchOption.TopDirectoryOnly)
.Select(x => (AbsolutePath)x.FullName);
}

internal static AbsolutePath GetParametersProfileFile(AbsolutePath rootDirectory, string profile)
{
return GetNukeDirectory(rootDirectory) / GetParametersFileName(profile);
return GetFalloutDirectory(rootDirectory) / GetParametersFileName(profile);
}

internal static string GetParametersFileName(string profile)
Expand Down
2 changes: 1 addition & 1 deletion src/Fallout.Build.Shared/Notifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal class NotificationFetcher
private const string NotificationEndpoint = Constants.FalloutNotificationsUrl;
private const string UtmMedium = "development";

private readonly AbsolutePath _notificationDirectory = Constants.GlobalNukeDirectory / "received-notifications";
private readonly AbsolutePath _notificationDirectory = Constants.GlobalFalloutDirectory / "received-notifications";
private readonly string _utmSource;

public NotificationFetcher(string utmSource)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ArgumentsFromParametersFileAttribute : BuildExtensionAttributeBase,
public void OnBuildCreated(IReadOnlyCollection<ExecutableTarget> executableTargets)
{
// TODO: probably remove
if (!Constants.GetNukeDirectory(FalloutBuild.RootDirectory).DirectoryExists())
if (!Constants.GetFalloutDirectory(FalloutBuild.RootDirectory).DirectoryExists())
return;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void OnBuildFinished()
Notify();
}

private bool ShouldNotify => !Directory.Exists(GetNukeDirectory(Build.RootDirectory)) &&
private bool ShouldNotify => !Directory.Exists(GetFalloutDirectory(Build.RootDirectory)) &&
!Build.IsInterceptorExecution;

private static void Notify()
Expand Down
2 changes: 1 addition & 1 deletion src/Fallout.Build/FalloutBuild.Statics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static AbsolutePath GetRootDirectory()
return TryGetRootDirectoryFrom(EnvironmentInfo.WorkingDirectory)
.NotNull(new[]
{
$"Could not locate '{NukeDirectoryName}' directory/file while walking up from '{EnvironmentInfo.WorkingDirectory}'.",
$"Could not locate '{FalloutDirectoryName}' directory/file while walking up from '{EnvironmentInfo.WorkingDirectory}'.",
"Either create a directory/file to mark the root directory, or add '--root [path]' to the invocation."
}.JoinNewLine());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fallout.Build/FalloutBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected static int Execute<T>(params Expression<Func<T, Target>>[] defaultTarg
BuildProjectFile == null
? Assembly.GetEntryAssembly().NotNull().Location != string.Empty
? BuildAssemblyDirectory
: GlobalNukeDirectory / "packages"
: GlobalFalloutDirectory / "packages"
: null;

internal IEnumerable<string> TargetNames => ExecutableTargetFactory.GetTargetProperties(GetType()).Select(x => x.GetDisplayShortName());
Expand Down
2 changes: 1 addition & 1 deletion src/Fallout.Build/Telemetry/Telemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static Telemetry()
private static int? CheckAwareness()
{
AbsolutePath GetCookieFile(string name, int version)
=> Constants.GlobalNukeDirectory / "telemetry-awareness" / $"v{version}" / name;
=> Constants.GlobalFalloutDirectory / "telemetry-awareness" / $"v{version}" / name;

// Check for calls from Fallout.GlobalTool and custom global tools
if (SuppressErrors(() => FalloutBuild.BuildProjectFile, logWarning: false) == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private static void ExtractPackageFiles()
if (!packageResourceNames.Any())
return;

var globalPackagesDirectory = Constants.GlobalNukeDirectory / "packages";
var globalPackagesDirectory = Constants.GlobalFalloutDirectory / "packages";
Log.Information("Extracting packages to {PackagesDirectory}", globalPackagesDirectory);

foreach (var packageResourceName in packageResourceNames)
Expand Down Expand Up @@ -76,7 +76,7 @@ private void InstallDotNetRuntime()
HttpTasks.HttpDownloadFile(ScriptUrl, ScriptFile);

var version = GetDotNetRuntimeVersion();
var installLocation = Constants.GlobalNukeDirectory / "dotnet-runtime" / (version ?? "current");
var installLocation = Constants.GlobalFalloutDirectory / "dotnet-runtime" / (version ?? "current");
var dotnetExecutable = installLocation / (EnvironmentInfo.IsWin ? "dotnet.exe" : "dotnet");

if (version == null || !dotnetExecutable.Exists())
Expand Down Expand Up @@ -104,7 +104,7 @@ private void InstallDotNetRuntime()
private bool IsSingleFileExecution => Assembly.GetEntryAssembly().NotNull().Location == string.Empty;

private string ScriptFileName => EnvironmentInfo.IsWin ? "dotnet-install.ps1" : "dotnet-install.sh";
private AbsolutePath ScriptFile => Constants.GlobalNukeDirectory / ScriptFileName;
private AbsolutePath ScriptFile => Constants.GlobalFalloutDirectory / ScriptFileName;

[CanBeNull]
private string GetDotNetRuntimeVersion()
Expand Down
6 changes: 3 additions & 3 deletions src/Fallout.Common/Attributes/SolutionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ private AbsolutePath GetSolutionFileFromParametersFile(MemberInfo member)

private AbsolutePath TryGetSolutionFileFromNukeFile()
{
var nukeFile = Build.RootDirectory / Constants.NukeFileName;
var nukeFile = Build.RootDirectory / Constants.FalloutFileName;
if (!nukeFile.Exists())
return null;

var solutionFileRelative = nukeFile.ReadAllLines().ElementAtOrDefault(0);
Assert.True(solutionFileRelative != null && !solutionFileRelative.Contains(value: '\\'),
$"First line of {Constants.NukeFileName} must provide solution path using UNIX separators");
$"First line of {Constants.FalloutFileName} must provide solution path using UNIX separators");

var solutionFile = Build.RootDirectory / solutionFileRelative;
Assert.FileExists(solutionFile, $"Solution file '{solutionFile}' provided via {Constants.NukeFileName} does not exist");
Assert.FileExists(solutionFile, $"Solution file '{solutionFile}' provided via {Constants.FalloutFileName} does not exist");

return solutionFile;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Fallout.GlobalTool/Program.Navigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ private static int PushWithChosenRootDirectory(string[] args, [CanBeNull] Absolu
{
return PushAndSetNext(() =>
{
var directories = EnvironmentInfo.WorkingDirectory.GlobDirectories($"**/{NukeDirectoryName}")
.Concat(EnvironmentInfo.WorkingDirectory.GlobFiles($"**/{NukeDirectoryName}"))
var directories = EnvironmentInfo.WorkingDirectory.GlobDirectories($"**/{FalloutDirectoryName}")
.Concat(EnvironmentInfo.WorkingDirectory.GlobFiles($"**/{FalloutDirectoryName}"))
.Where(x => !x.Equals(EnvironmentInfo.WorkingDirectory))
.Select(x => x.Parent)
.Select(x => (x, EnvironmentInfo.WorkingDirectory.GetRelativePathTo(x).ToString()))
Expand Down
8 changes: 4 additions & 4 deletions src/Fallout.GlobalTool/Program.Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public static int Setup(string[] args, [CanBeNull] AbsolutePath rootDirectory, [

#region Basic

var nukeLatestReleaseVersion = NuGetVersionResolver.GetLatestVersion(NukeCommonPackageId, includePrereleases: false);
var nukeLatestPrereleaseVersion = NuGetVersionResolver.GetLatestVersion(NukeCommonPackageId, includePrereleases: true);
var nukeLatestLocalVersion = NuGetPackageResolver.GetGlobalInstalledPackage(NukeCommonPackageId, version: null, packagesConfigFile: null)
var nukeLatestReleaseVersion = NuGetVersionResolver.GetLatestVersion(FalloutCommonPackageId, includePrereleases: false);
var nukeLatestPrereleaseVersion = NuGetVersionResolver.GetLatestVersion(FalloutCommonPackageId, includePrereleases: true);
var nukeLatestLocalVersion = NuGetPackageResolver.GetGlobalInstalledPackage(FalloutCommonPackageId, version: null, packagesConfigFile: null)
?.Version.ToString();

if (rootDirectory == null)
Expand Down Expand Up @@ -99,7 +99,7 @@ public static int Setup(string[] args, [CanBeNull] AbsolutePath rootDirectory, [
var buildProjectFile = rootDirectory / buildProjectRelativeDirectory / buildProjectName + ".csproj";
var buildProjectGuid = Guid.NewGuid().ToString().ToUpper();

(rootDirectory / NukeDirectoryName).CreateDirectory();
(rootDirectory / FalloutDirectoryName).CreateDirectory();

WriteBuildScripts(
scriptDirectory: WorkingDirectory,
Expand Down
6 changes: 3 additions & 3 deletions src/Fallout.GlobalTool/Program.Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ private static void UpdateBuildProject(AbsolutePath buildScript)

private static void UpdateConfigurationFile(AbsolutePath rootDirectory)
{
var configurationFile = rootDirectory / NukeDirectoryName;
var configurationFile = rootDirectory / FalloutDirectoryName;
if (!configurationFile.Exists())
return;

var solutionFile = rootDirectory / configurationFile.ReadAllLines().FirstOrDefault(x => !x.IsNullOrEmpty());
configurationFile.DeleteFile();

WriteConfigurationFile(rootDirectory, solutionFile);
Host.Warning($"The previous {NukeFileName} file was transformed to a {NukeDirectoryName} directory.");
Host.Warning($"The .tmp directory can be cleared, as it is moved to {NukeDirectoryName}/temp as well.");
Host.Warning($"The previous {FalloutFileName} file was transformed to a {FalloutDirectoryName} directory.");
Host.Warning($"The .tmp directory can be cleared, as it is moved to {FalloutDirectoryName}/temp as well.");
if (solutionFile != null)
Host.Warning($"Verify the property referencing the solution has the same name as the member with the {nameof(SolutionAttribute)}.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fallout.GlobalTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private static int Handle(string[] args, [CanBeNull] AbsolutePath rootDirectory,
if (rootDirectory == null || buildScript == null)
{
var missingItem = rootDirectory == null
? $"{Constants.NukeDirectoryName} directory/file"
? $"{Constants.FalloutDirectoryName} directory/file"
: "build.ps1/sh files";

return PromptForConfirmation($"Could not find {missingItem}. Do you want to setup a build?")
Expand Down
4 changes: 2 additions & 2 deletions src/Fallout.GlobalTool/ProjectUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ private static void UpdateTargetFramework(Microsoft.Build.Evaluation.Project bui

private static void UpdateNukeCommonPackage(Microsoft.Build.Evaluation.Project buildProject, out FloatRange previousPackageVersion)
{
var packageItem = buildProject.Items.SingleOrDefault(x => x.EvaluatedInclude == Constants.NukeCommonPackageId).NotNull();
var packageItem = buildProject.Items.SingleOrDefault(x => x.EvaluatedInclude == Constants.FalloutCommonPackageId).NotNull();
previousPackageVersion = FloatRange.Parse(packageItem.GetMetadataValue("Version"));

var latestPackageVersion = NuGetVersionResolver.GetLatestVersion(Constants.NukeCommonPackageId, includePrereleases: false).GetAwaiter().GetResult();
var latestPackageVersion = NuGetVersionResolver.GetLatestVersion(Constants.FalloutCommonPackageId, includePrereleases: false).GetAwaiter().GetResult();
if (previousPackageVersion.Satisfies(NuGetVersion.Parse(latestPackageVersion)))
return;

Expand Down
Loading