Skip to content
Permalink
Browse files

[Assets] Fixed asset compiler get-graphics-platform

  • Loading branch information
xen2 committed Sep 10, 2018
1 parent 7761135 commit afae09c147b784785b0abfafa5b01a5d2e5ddba5
@@ -58,6 +58,19 @@ public BuildResultCode Build()

private BuildResultCode BuildMaster()
{
try
{
PackageSessionPublicHelper.FindAndSetMSBuildVersion();
}
catch (Exception e)
{
var message = "Could not find a compatible version of MSBuild.\r\n\r\n" +
"Check that you have a valid installation with the required workloads, or go to [www.visualstudio.com/downloads](https://www.visualstudio.com/downloads) to install a new one.\r\n\r\n" +
e;
builderOptions.Logger.Error(message);
return BuildResultCode.BuildError;
}

// Only querying graphics platform, let's load package, print it and exit
if (builderOptions.GetGraphicsPlatform)
{
@@ -68,19 +81,6 @@ private BuildResultCode BuildMaster()
PackageSession projectSession = null;
try
{
try
{
PackageSessionPublicHelper.FindAndSetMSBuildVersion();
}
catch (Exception e)
{
var message = "Could not find a compatible version of MSBuild.\r\n\r\n" +
"Check that you have a valid installation with the required workloads, or go to [www.visualstudio.com/downloads](https://www.visualstudio.com/downloads) to install a new one.\r\n\r\n" +
e;
builderOptions.Logger.Error(message);
return BuildResultCode.BuildError;
}

var sessionLoadParameters = new PackageLoadParameters
{
AutoCompileProjects = !builderOptions.DisableAutoCompileProjects,
@@ -174,20 +174,21 @@ private BuildResultCode BuildMaster()

private BuildResultCode BuildGetGraphicsPlatform()
{
var localLogger = new LoggerResult();
var simplePackage = Package.Load(localLogger, builderOptions.PackageFile, new PackageLoadParameters
var loadParameters = new PackageLoadParameters
{
AutoLoadTemporaryAssets = true,
LoadAssemblyReferences = false,
AutoCompileProjects = false,
TemporaryAssetFilter = (asset) => asset.AssetLocation == GameSettingsAsset.GameSettingsLocation,
TemporaryAssetsInMsbuild = false,
});
};
var sessionResult = PackageSession.Load(builderOptions.PackageFile, loadParameters);
var simplePackage = sessionResult.Session.Packages.First();
sessionResult.Session.LoadMissingReferences(sessionResult, loadParameters);

if (simplePackage == null
|| localLogger.HasErrors)
if (simplePackage == null || sessionResult.HasErrors)
{
localLogger.CopyTo(builderOptions.Logger);
sessionResult.CopyTo(builderOptions.Logger);
return BuildResultCode.BuildError;
}

@@ -702,7 +702,7 @@ public static Guid GetPackageIdFromFile(string filePath)
/// filePath</exception>
public static Package Load(ILogger log, string filePath, PackageLoadParameters loadParametersArg = null)
{
var package = LoadRaw(log, filePath);
var package = LoadProject(log, filePath)?.Package;

if (package != null)
{
@@ -761,6 +761,33 @@ internal static Package LoadRaw(ILogger log, string filePath)
return null;
}

public static PackageContainer LoadProject(ILogger log, string filePath)
{
if (Path.GetExtension(filePath).ToLowerInvariant() == ".csproj")
{
var projectPath = filePath;
var packagePath = Path.ChangeExtension(filePath, Package.PackageFileExtension);
var package = LoadRaw(log, packagePath);
return new SolutionProject(package, package.Id, projectPath);
}
else
{
var package = LoadRaw(log, filePath);

// Find the .csproj next to .xkpkg (if any)
// Note that we use package.FullPath since we must first perform package upgrade from 3.0 to 3.1+ (might move package in .csproj folder)
var projectPath = Path.ChangeExtension(package.FullPath, ".csproj");
if (File.Exists(projectPath))
{
return new SolutionProject(package, package.Id, projectPath);
}
else
{
return new StandalonePackage(package);
}
}
}

/// <summary>
/// Second part of the package loading process, when references, assets and package analysis is done.
/// </summary>
@@ -1381,6 +1408,7 @@ protected override void UpgradeAsset(AssetMigrationContext context, PackageVersi
{
var projectLocation = (UFile)(string)profile.ProjectReferences[0].Location;
assetFile.FilePath = UPath.Combine(assetFile.OriginalFilePath.GetFullDirectory(), (UFile)(projectLocation.GetFullPathWithoutExtension() + PackageFileExtension));
asset.Meta.Name = projectLocation.GetFileNameWithoutExtension();

for (int i = 0; i < profile.AssetFolders.Count; ++i)
{
@@ -478,29 +478,25 @@ public AssetItem FindAssetFromProxyObject(object proxyObject)

private PackageContainer LoadProject(ILogger log, string filePath, bool isSystem, PackageLoadParameters loadParameters = null)
{
if (Path.GetExtension(filePath).ToLowerInvariant() == ".csproj")
var project = Package.LoadProject(log, filePath);

var package = project.Package;
package.IsSystem = isSystem;

// If the package doesn't have a meta name, fix it here (This is supposed to be done in the above disabled analysis - but we still need to do it!)
if (string.IsNullOrWhiteSpace(package.Meta.Name) && package.FullPath != null)
{
var projectPath = filePath;
var packagePath = Path.ChangeExtension(filePath, Package.PackageFileExtension);
var package = PreLoadPackage(log, packagePath, isSystem, loadParameters);
return new SolutionProject(package, package.Id, projectPath);
package.Meta.Name = package.FullPath.GetFileNameWithoutExtension();
package.IsDirty = true;
}
else
{
var package = PreLoadPackage(log, filePath, isSystem, loadParameters);

// Find the .csproj next to .xkpkg (if any)
// Note that we use package.FullPath since we must first perform package upgrade from 3.0 to 3.1+ (might move package in .csproj folder)
var projectPath = Path.ChangeExtension(package.FullPath, ".csproj");
if (File.Exists(projectPath))
{
return new SolutionProject(package, package.Id, projectPath);
}
else
{
return new StandalonePackage(package);
}
// Package has been loaded, register it in constraints so that we force each subsequent loads to use this one (or fails if version doesn't match)
if (package.Meta.Version != null)
{
constraintProvider.AddConstraint(package.Meta.Name, new PackageVersionRange(package.Meta.Version));
}

return project;
}

/// <summary>

0 comments on commit afae09c

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