-
Notifications
You must be signed in to change notification settings - Fork 223
Change output structure of "kpm pack" #433
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,25 +41,20 @@ public void EmitSource(PackRoot root) | |
| throw new Exception("TODO: unable to resolve project named " + _libraryDescription.Identity.Name); | ||
| } | ||
|
|
||
| var targetName = AppFolder ?? project.Name; | ||
| var targetName = project.Name; | ||
| TargetPath = Path.Combine(root.OutputPath, PackRoot.AppRootName, "src", targetName); | ||
|
|
||
| Console.WriteLine(" Source {0}", project.ProjectDirectory); | ||
| Console.WriteLine(" Target {0}", TargetPath); | ||
|
|
||
| root.Operations.Delete(TargetPath); | ||
|
|
||
| // A set of excluded source files used as a filter when doing copy | ||
| var sourceExcludeFiles = new HashSet<string>(project.SourceExcludeFiles, StringComparer.OrdinalIgnoreCase); | ||
| // A set of excluded files used as a filter when doing copy | ||
| var excludeFiles = new HashSet<string>(project.ExcludeFiles, StringComparer.OrdinalIgnoreCase); | ||
|
|
||
| root.Operations.Copy(project.ProjectDirectory, TargetPath, (isRoot, filePath) => | ||
| { | ||
| if (IsImplicitlyExcludedFile(filePath)) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| if (sourceExcludeFiles.Contains(filePath)) | ||
| if (excludeFiles.Contains(filePath)) | ||
| { | ||
| return false; | ||
| } | ||
|
|
@@ -78,7 +73,7 @@ public void EmitNupkg(PackRoot root) | |
| throw new Exception("TODO: unable to resolve project named " + _libraryDescription.Identity.Name); | ||
| } | ||
|
|
||
| var targetName = AppFolder ?? project.Name; | ||
| var targetName = project.Name; | ||
| var targetNupkgName = string.Format("{0}.{1}", targetName, project.Version); | ||
| TargetPath = Path.Combine(root.OutputPath, PackRoot.AppRootName, "packages", targetNupkgName); | ||
|
|
||
|
|
@@ -132,28 +127,29 @@ public void EmitNupkg(PackRoot root) | |
| } | ||
| } | ||
|
|
||
| private static bool IsImplicitlyExcludedFile(string filePath) | ||
| public void PostProcess(PackRoot root) | ||
| { | ||
| var fileExtension = Path.GetExtension(filePath); | ||
| var fileName = Path.GetFileName(filePath); | ||
|
|
||
| if (string.Equals(fileExtension, ".csproj", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(fileExtension, ".kproj", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(fileExtension, ".user", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(fileExtension, ".vspscc", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(fileExtension, ".vssscc", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(fileExtension, ".pubxml", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(fileName, "bin", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(fileName, "obj", StringComparison.OrdinalIgnoreCase)) | ||
| Project project; | ||
| if (!_projectResolver.TryResolveProject(_libraryDescription.Identity.Name, out project)) | ||
| { | ||
| return true; | ||
| throw new Exception("TODO: unable to resolve project named " + _libraryDescription.Identity.Name); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public void PostProcess(PackRoot root) | ||
| { | ||
| var binFolderPath = Path.Combine(TargetPath, "bin"); | ||
| // Construct path to public app folder, which contains content files and tool dlls | ||
| // The name of public app folder is specified with "--appfolder" option | ||
| // Default name of public app folder is the same as main project | ||
| var appFolderName = AppFolder ?? PackRoot.DefaultAppFolderName; | ||
| var appFolderPath = Path.Combine(root.OutputPath, appFolderName); | ||
|
|
||
| // Delete old public app folder because we don't want leftovers from previous operations | ||
| root.Operations.Delete(appFolderPath); | ||
| Directory.CreateDirectory(appFolderPath); | ||
|
|
||
| // Copy content files (e.g. html, js and images) of main project into public app folder | ||
| CopyContentFiles(root, project, appFolderName); | ||
|
|
||
| // Tool dlls including AspNet.Loader.dll go to bin folder under public app folder | ||
| var appFolderBinPath = Path.Combine(appFolderPath, "bin"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the difference between these folders There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the main project\bin relevant? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we don't need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What goes in it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea that's useless. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this the wwwroot or the main app? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's public app folder (i.e. |
||
|
|
||
| var defaultRuntime = root.Runtimes.FirstOrDefault(); | ||
| var iniFilePath = Path.Combine(TargetPath, "k.ini"); | ||
|
|
@@ -179,6 +175,18 @@ public void PostProcess(PackRoot root) | |
| } | ||
| } | ||
|
|
||
| // Generate k.ini for public app folder | ||
| var appFolderIniFilePath = Path.Combine(appFolderPath, "k.ini"); | ||
| var appBaseLine = string.Format("APP_BASE={0}", | ||
| Path.Combine("..", PackRoot.AppRootName, "src", project.Name)); | ||
| var iniContents = string.Empty; | ||
| if (File.Exists(iniFilePath)) | ||
| { | ||
| iniContents = File.ReadAllText(iniFilePath); | ||
| } | ||
| File.WriteAllText(appFolderIniFilePath, | ||
| string.Format("{0}{1}", iniContents, appBaseLine)); | ||
|
|
||
| // Copy tools/*.dll into bin to support AspNet.Loader.dll | ||
| foreach (var package in root.Packages) | ||
| { | ||
|
|
@@ -187,74 +195,51 @@ public void PostProcess(PackRoot root) | |
| { | ||
| foreach (var packageToolFile in Directory.EnumerateFiles(packageToolsPath, "*.dll").Select(Path.GetFileName)) | ||
| { | ||
| if (!Directory.Exists(binFolderPath)) | ||
| if (!Directory.Exists(appFolderBinPath)) | ||
| { | ||
| Directory.CreateDirectory(binFolderPath); | ||
| Directory.CreateDirectory(appFolderBinPath); | ||
| } | ||
|
|
||
| // Copy to bin folder under public app folder | ||
| File.Copy( | ||
| Path.Combine(packageToolsPath, packageToolFile), | ||
| Path.Combine(binFolderPath, packageToolFile), | ||
| Path.Combine(appFolderBinPath, packageToolFile), | ||
| true); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private void CopyContentFiles(PackRoot root, Project project, string appFolderName) | ||
| { | ||
| Console.WriteLine("Copying contents of project dependency {0} to {1}", | ||
| _libraryDescription.Identity.Name, appFolderName); | ||
|
|
||
| // Copy lib/**/*.dll into bin/$xxxxxxx.packages to support web deploy | ||
| if (root.ZipPackages) | ||
| var appFolderPath = Path.Combine(root.OutputPath, appFolderName); | ||
|
|
||
| Console.WriteLine(" Source {0}", project.ProjectDirectory); | ||
| Console.WriteLine(" Target {0}", appFolderPath); | ||
|
|
||
| // A set of content files that should be copied | ||
| var contentFiles = new HashSet<string>(project.ContentFiles, StringComparer.OrdinalIgnoreCase); | ||
|
|
||
| root.Operations.Copy(project.ProjectDirectory, appFolderPath, (isRoot, filePath) => | ||
| { | ||
| if (!Directory.Exists(binFolderPath)) | ||
| // We always explore a directory | ||
| if (Directory.Exists(filePath)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We call this for directories as well? Why is that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, exploring a dir doesn't mean we copy it. We only create the dir in destination when there is a file in it needs to be copied. |
||
| { | ||
| Directory.CreateDirectory(binFolderPath); | ||
| return true; | ||
| } | ||
|
|
||
| var chars = "abcdefghijklmnopqrstuvwxyz0123456789"; | ||
| var rnd = new Random(); | ||
| var sequence = new string(Enumerable.Range(0, 7).Select(_ => chars[rnd.Next(chars.Length)]).ToArray()); | ||
| var targetFile = Path.Combine(binFolderPath, "$" + sequence + ".packages"); | ||
|
|
||
| using (var targetStream = new FileStream(targetFile, FileMode.Create, FileAccess.Write, FileShare.None)) | ||
| var fileName = Path.GetFileName(filePath); | ||
| // Public app folder doesn't need project.json | ||
| if (string.Equals(fileName, "project.json", StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| using (var archive = new ZipArchive(targetStream, ZipArchiveMode.Create)) | ||
| { | ||
| foreach (var package in root.Packages) | ||
| { | ||
| root.Operations.AddFiles( | ||
| archive, | ||
| package.TargetPath, | ||
| Path.Combine("packages", package.Library.Name + "." + package.Library.Version), | ||
| IncludePackageFileInBundle); | ||
| } | ||
| foreach (var runtime in root.Runtimes) | ||
| { | ||
| //root.Operations.AddFiles( | ||
| // archive, | ||
| // root.Runtime.TargetPath, | ||
| // Path.Combine("packages", root.Runtime.Name + "." + root.Runtime.Version), | ||
| // IncludeRuntimeFileInBundle); | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private bool IncludePackageFileInBundle(string relativePath, string fileName) | ||
| { | ||
| var fileExtension = Path.GetExtension(fileName); | ||
| var rootFolder = BasePath(relativePath); | ||
|
|
||
| if (/*string.Equals(rootFolder, "lib", StringComparison.OrdinalIgnoreCase) && */ | ||
| string.Equals(fileExtension, ".dll", StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| return true; | ||
| } | ||
| if (string.IsNullOrEmpty(relativePath) && | ||
| (string.Equals(fileExtension, ".sha512", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(fileExtension, ".nuspec", StringComparison.OrdinalIgnoreCase))) | ||
| { | ||
| return true; | ||
| } | ||
| return false; | ||
| return contentFiles.Contains(filePath); | ||
| }); | ||
| } | ||
|
|
||
| private bool IncludeRuntimeFileInBundle(string relativePath, string fileName) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this get removed as part of this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change of Helios and app layout makes bundled packages useless. So you want this change to be made in another PR?