Skip to content
Permalink
Browse files

[Assets] Properly regenerate platforms for sample templates

  • Loading branch information
xen2 committed Sep 11, 2018
1 parent 0e1ad23 commit ab92536a9daaf98c8327b1ec42ac91286501bea8
@@ -352,9 +352,8 @@ protected override async Task<bool> AfterSave(SessionTemplateGeneratorParameters
// Save again post update
SaveSession(parameters);

// Restore NuGet packages again
parameters.Logger.Verbose("Restore NuGet packages...");
await VSProjectHelper.RestoreNugetPackages(parameters.Logger, parameters.Session.SolutionPath);
// Make sure platform projects also gets in fully loaded state
package.Session.LoadMissingReferences(parameters.Logger);

return true;
}
@@ -80,7 +80,7 @@ public static void UpdatePackagePlatforms(TemplateGeneratorParameters parameters

// Don't add a platform that is already in the package
var projectName = Utilities.BuildValidNamespaceName(name) + "." + platform.Platform.Name;
var projectFullPath = UPath.Combine(package.RootDirectory.GetParent(), (UFile)(projectName + ".csproj"));
var projectFullPath = UPath.Combine(UPath.Combine(package.RootDirectory.GetParent(), (UDirectory)projectName), (UFile)(projectName + ".csproj"));
var existingProject = package.Session.Projects.OfType<SolutionProject>().FirstOrDefault(x => x.FullPath == projectFullPath);

var projectGuid = Guid.NewGuid();
@@ -94,17 +94,18 @@ public static void UpdatePackagePlatforms(TemplateGeneratorParameters parameters

// We are going to regenerate this platform, so we are removing it before
package.Session.Projects.Remove(existingProject);
var projectDirectory = Path.GetDirectoryName(projectFullPath);
if (projectDirectory != null && Directory.Exists(projectDirectory))
}

var projectDirectory = Path.GetDirectoryName(projectFullPath.ToWindowsPath());
if (projectDirectory != null && Directory.Exists(projectDirectory))
{
try
{
try
{
Directory.Delete(projectDirectory, true);
}
catch (Exception)
{
logger.Warning($"Unable to delete directory [{projectDirectory}]");
}
Directory.Delete(projectDirectory, true);
}
catch (Exception)
{
logger.Warning($"Unable to delete directory [{projectDirectory}]");
}
}

@@ -118,8 +119,6 @@ public static void UpdatePackagePlatforms(TemplateGeneratorParameters parameters

package.Session.Projects.Add(newExeProject);

package.Session.LoadMissingReferences(logger);

package.IsDirty = true;
}
}

0 comments on commit ab92536

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