Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
Partial publish fixes
Browse files Browse the repository at this point in the history
- Fix slash resolution for lock file
- Skip running events when generating lock file after copy

#1839 #1832 #1833
  • Loading branch information
davidfowl committed May 11, 2015
1 parent c076b04 commit e08630a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
14 changes: 10 additions & 4 deletions src/Microsoft.Framework.PackageManager/Publish/PublishProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,22 +341,22 @@ private bool PrunePackages(PublishRoot root)

foreach (var path in library.RuntimeAssemblies)
{
keep.Add(Path.Combine(packagesDir, path));
keep.Add(CombinePath(packagesDir, path));
}

foreach (var path in library.CompileTimeAssemblies)
{
keep.Add(Path.Combine(packagesDir, path));
keep.Add(CombinePath(packagesDir, path));
}

foreach (var path in library.NativeLibraries)
{
keep.Add(Path.Combine(packagesDir, path));
keep.Add(CombinePath(packagesDir, path));
}

foreach (var specialFolder in specialFolders)
{
var specialFolderPath = Path.Combine(packagesDir, specialFolder);
var specialFolderPath = CombinePath(packagesDir, specialFolder);

if (!Directory.Exists(specialFolderPath))
{
Expand Down Expand Up @@ -388,6 +388,11 @@ private bool PrunePackages(PublishRoot root)
return true;
}

private static string CombinePath(string path1, string path2)
{
return Path.Combine(path1, path2.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar));
}

private bool UpdateLockFile(PublishRoot root)
{
var appEnv = (IApplicationEnvironment)root.HostServices.GetService(typeof(IApplicationEnvironment));
Expand All @@ -408,6 +413,7 @@ private bool UpdateLockFile(PublishRoot root)
restoreCommand.TargetFrameworks.Add(runtime.Framework);
}

restoreCommand.SkipRestoreEvents = true;
restoreCommand.SkipInstall = true;
restoreCommand.CheckHashFile = false;
restoreCommand.RestoreDirectory = project.IsPackage ? Path.Combine(project.TargetPath, "root") : project.TargetPath;
Expand Down
35 changes: 21 additions & 14 deletions src/Microsoft.Framework.PackageManager/Restore/RestoreCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public RestoreCommand(FrameworkName fallbackFramework)
public Reports Reports { get; set; }
public bool CheckHashFile { get; set; } = true;
public bool SkipInstall { get; set; }
public bool SkipRestoreEvents { get; set; }

private Dictionary<string, List<string>> ErrorMessages { get; set; }

Expand Down Expand Up @@ -210,11 +211,14 @@ private async Task<bool> RestoreForProject(string projectJsonPath, string rootDi
return null;
};

if (!ScriptExecutor.Execute(project, "prerestore", getVariable))
if (!SkipRestoreEvents)
{
ErrorMessages.GetOrAdd("prerestore", _ => new List<string>()).Add(ScriptExecutor.ErrorMessage);
Reports.Error.WriteLine(ScriptExecutor.ErrorMessage);
return false;
if (!ScriptExecutor.Execute(project, "prerestore", getVariable))
{
ErrorMessages.GetOrAdd("prerestore", _ => new List<string>()).Add(ScriptExecutor.ErrorMessage);
Reports.Error.WriteLine(ScriptExecutor.ErrorMessage);
return false;
}
}

var projectDirectory = project.ProjectDirectory;
Expand Down Expand Up @@ -471,18 +475,21 @@ private async Task<bool> RestoreForProject(string projectJsonPath, string rootDi
targetContexts);
}

if (!ScriptExecutor.Execute(project, "postrestore", getVariable))
if (!SkipRestoreEvents)
{
ErrorMessages.GetOrAdd("postrestore", _ => new List<string>()).Add(ScriptExecutor.ErrorMessage);
Reports.Error.WriteLine(ScriptExecutor.ErrorMessage);
return false;
}
if (!ScriptExecutor.Execute(project, "postrestore", getVariable))
{
ErrorMessages.GetOrAdd("postrestore", _ => new List<string>()).Add(ScriptExecutor.ErrorMessage);
Reports.Error.WriteLine(ScriptExecutor.ErrorMessage);
return false;
}

if (!ScriptExecutor.Execute(project, "prepare", getVariable))
{
ErrorMessages.GetOrAdd("prepare", _ => new List<string>()).Add(ScriptExecutor.ErrorMessage);
Reports.Error.WriteLine(ScriptExecutor.ErrorMessage);
return false;
if (!ScriptExecutor.Execute(project, "prepare", getVariable))
{
ErrorMessages.GetOrAdd("prepare", _ => new List<string>()).Add(ScriptExecutor.ErrorMessage);
Reports.Error.WriteLine(ScriptExecutor.ErrorMessage);
return false;
}
}

Reports.Information.WriteLine(string.Format("{0}, {1}ms elapsed", "Restore complete".Green().Bold(), sw.ElapsedMilliseconds));
Expand Down

0 comments on commit e08630a

Please sign in to comment.