Skip to content
Permalink
Browse files

[Assets] Avoid creating .xkpkg for projects without one in the first …

…place (use implicit one instead)
  • Loading branch information
xen2 committed Sep 19, 2018
1 parent 7d43032 commit f375ae16cbe3e8ed0f40b3a257d010d585b39197
@@ -592,8 +592,16 @@ public static PackageContainer LoadProject(ILogger log, string filePath)
{
var projectPath = filePath;
var packagePath = Path.ChangeExtension(filePath, Package.PackageFileExtension);
var package = LoadRaw(log, packagePath);
return new SolutionProject(package, Guid.NewGuid(), projectPath);
var packageExists = File.Exists(packagePath);
var package = packageExists
? LoadRaw(log, packagePath)
: new Package
{
Meta = { Name = Path.GetFileNameWithoutExtension(packagePath) },
AssetFolders = { new AssetFolder("Assets") },
ResourceFolders = { "Resources" },
};
return new SolutionProject(package, Guid.NewGuid(), projectPath) { IsImplicitProject = !packageExists };
}
else
{
@@ -90,7 +90,7 @@ public void Save(ILogger log, PackageSaveParameters saveParameters = null)

try
{
AssetFileSerializer.Save(Package.FullPath, Package, null);
SavePackage();

// Move the package if the path has changed
if (Package.PreviousPackagePath != null && Package.PreviousPackagePath != Package.FullPath)
@@ -207,6 +207,11 @@ public void Save(ILogger log, PackageSaveParameters saveParameters = null)
}
}

protected virtual void SavePackage()
{
AssetFileSerializer.Save(Package.FullPath, Package, null);
}

internal void SetSessionInternal(PackageSession session)
{
Session = session;
@@ -298,13 +303,21 @@ public SolutionProject([NotNull] Package package, VisualStudio.Project vsProject

public PlatformType Platform { get; set; }

public bool IsImplicitProject { get; set; }

public string Name => VSProject.Name;

public UFile FullPath => VSProject.FullPath;

public ObservableCollection<DependencyRange> DirectDependencies { get; } = new ObservableCollection<DependencyRange>();

public ObservableCollection<Dependency> FlattenedDependencies { get; } = new ObservableCollection<Dependency>();

protected override void SavePackage()
{
if (!IsImplicitProject)
base.SavePackage();
}
}

public sealed class ProjectCollection : ObservableCollection<PackageContainer>
@@ -143,7 +143,8 @@ public static void Build(ILogger log, Package package, string outputDirectory =
var newPackageFileName = "temp" + Guid.NewGuid() + ".xkpkg";
newPackage.FullPath = package.RootDirectory + "/" + newPackageFileName;
var result = new LoggerResult();
newPackage.Save(result);
var standalonePackage = new StandalonePackage(newPackage);
standalonePackage.Save(result);
if (result.HasErrors)
{
throw new InvalidOperationException(result.ToText());

0 comments on commit f375ae1

Please sign in to comment.
You can’t perform that action at this time.