mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Changing system.io.packaging to nupack for packaging
PackageBuilder changed to produce opc binary through nupack Affected code in PackageManager and PackageExpander disabled by #if REFACTORING --HG-- branch : nuget extra : transplant_source : %16%B0%AA%E7%24H/%D3%08%FBz%3D%83%94%26s%3F%99%B5%C8
This commit is contained in:
@@ -1 +1 @@
|
||||
0000000000000000000000000000000000000000 external/nupack
|
||||
230ef1360257ef0ac622f6e85a94323ef2e49cae external/nupack
|
||||
|
@@ -67,9 +67,6 @@
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.EnterpriseServices" />
|
||||
<Reference Include="WindowsBase">
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
@@ -113,6 +110,10 @@
|
||||
<Folder Include="Scripts\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\external\nupack\NuPack.Core\NuPack.Core.csproj">
|
||||
<Project>{F879F274-EFA0-4157-8404-33A19B4E6AEC}</Project>
|
||||
<Name>NuPack.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
|
||||
<Name>Orchard.Framework</Name>
|
||||
|
@@ -1,17 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Packaging;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
using System.Web.Hosting;
|
||||
using System.Xml.Linq;
|
||||
using NuPack;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.FileSystems.WebSite;
|
||||
|
||||
using NuPack_PackageBuilder = NuPack.PackageBuilder;
|
||||
using NuPack_IPackageBuilder = NuPack.IPackageBuilder;
|
||||
|
||||
namespace Orchard.Packaging.Services {
|
||||
[OrchardFeature("PackagingServices")]
|
||||
public class PackageBuilder : IPackageBuilder {
|
||||
@@ -36,7 +39,6 @@ namespace Orchard.Packaging.Services {
|
||||
_webSiteFolder = webSiteFolder;
|
||||
}
|
||||
|
||||
#region IPackageBuilder Members
|
||||
|
||||
public Stream BuildPackage(ExtensionDescriptor extensionDescriptor) {
|
||||
var context = new CreateContext();
|
||||
@@ -67,26 +69,14 @@ namespace Orchard.Packaging.Services {
|
||||
return context.Stream;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private void SetCoreProperties(CreateContext context, ExtensionDescriptor extensionDescriptor) {
|
||||
PackageProperties properties = context.Package.PackageProperties;
|
||||
properties.Title = extensionDescriptor.DisplayName ?? extensionDescriptor.Name;
|
||||
//properties.Subject = "";
|
||||
properties.Creator = extensionDescriptor.Author;
|
||||
properties.Keywords = extensionDescriptor.Tags;
|
||||
properties.Description = extensionDescriptor.Description;
|
||||
//properties.LastModifiedBy = "";
|
||||
//properties.Revision = "";
|
||||
//properties.LastPrinted = "";
|
||||
//properties.Created = "";
|
||||
//properties.Modified = "";
|
||||
properties.Category = extensionDescriptor.Features.Where(f => f.Name == extensionDescriptor.Name).Select(f => f.Category).FirstOrDefault();
|
||||
properties.Identifier = extensionDescriptor.Name;
|
||||
properties.ContentType = "Orchard " + extensionDescriptor.ExtensionType;
|
||||
//properties.Language = "";
|
||||
properties.Version = extensionDescriptor.Version;
|
||||
properties.ContentStatus = "";
|
||||
context.Builder.Id = extensionDescriptor.Name;
|
||||
context.Builder.Version = new Version(extensionDescriptor.Version);
|
||||
context.Builder.Title = extensionDescriptor.DisplayName ?? extensionDescriptor.Name;
|
||||
context.Builder.Description = extensionDescriptor.Description;
|
||||
context.Builder.Authors.Add(extensionDescriptor.Author);
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +115,7 @@ namespace Orchard.Packaging.Services {
|
||||
if (context.SourceFolder.FileExists(context.SourcePath + virtualPath)) {
|
||||
EmbedVirtualFile(context, virtualPath, MediaTypeNames.Application.Octet);
|
||||
}
|
||||
else if (hintPath != null) {}
|
||||
else if (hintPath != null) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,8 +140,7 @@ namespace Orchard.Packaging.Services {
|
||||
|
||||
|
||||
private static void BeginPackage(CreateContext context) {
|
||||
context.Stream = new MemoryStream();
|
||||
context.Package = Package.Open(context.Stream, FileMode.Create, FileAccess.ReadWrite);
|
||||
context.Builder = new NuPack_PackageBuilder();
|
||||
}
|
||||
|
||||
private static void EstablishPaths(CreateContext context, IWebSiteFolder webSiteFolder, string locationPath, string moduleName, string moduleType) {
|
||||
@@ -174,24 +163,24 @@ namespace Orchard.Packaging.Services {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Uri EmbedVirtualFile(CreateContext context, string relativePath, string contentType) {
|
||||
Uri partUri = PackUriHelper.CreatePartUri(new Uri(context.TargetPath + relativePath, UriKind.Relative));
|
||||
PackagePart packagePart = context.Package.CreatePart(partUri, contentType);
|
||||
using (Stream stream = packagePart.GetStream(FileMode.Create, FileAccess.Write)) {
|
||||
context.SourceFolder.CopyFileTo(context.SourcePath + relativePath, stream, true /*actualContent*/);
|
||||
}
|
||||
return partUri;
|
||||
private static void EmbedVirtualFile(CreateContext context, string relativePath, string contentType) {
|
||||
var file = new VirtualPackageFile(context.SourceFolder, context.SourcePath + relativePath);
|
||||
context.Builder.Files.Add(file);
|
||||
}
|
||||
|
||||
|
||||
private static void EndPackage(CreateContext context) {
|
||||
context.Package.Close();
|
||||
context.Stream = new MemoryStream();
|
||||
context.Builder.Save(context.Stream);
|
||||
}
|
||||
|
||||
#region Nested type: CreateContext
|
||||
|
||||
private class CreateContext {
|
||||
public Stream Stream { get; set; }
|
||||
public Package Package { get; set; }
|
||||
//public Package Package { get; set; }
|
||||
//public Manifest Manifest { get; set; }
|
||||
public NuPack_PackageBuilder Builder { get; set; }
|
||||
|
||||
public IWebSiteFolder SourceFolder { get; set; }
|
||||
public string SourcePath { get; set; }
|
||||
@@ -201,5 +190,29 @@ namespace Orchard.Packaging.Services {
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Nested type: CreateContext
|
||||
|
||||
private class VirtualPackageFile : IPackageFile {
|
||||
private readonly IWebSiteFolder _sourceFolder;
|
||||
|
||||
public VirtualPackageFile(IWebSiteFolder sourceFolder, string path) {
|
||||
Path = path;
|
||||
_sourceFolder = sourceFolder;
|
||||
}
|
||||
|
||||
public string Path { get; private set; }
|
||||
|
||||
public Stream GetStream() {
|
||||
var stream = new MemoryStream();
|
||||
_sourceFolder.CopyFileTo(Path, stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Packaging;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Xml.Linq;
|
||||
@@ -23,7 +22,6 @@ namespace Orchard.Packaging.Services {
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
#region IPackageExpander Members
|
||||
|
||||
public PackageInfo ExpandPackage(Stream packageStream) {
|
||||
var context = new ExpandContext();
|
||||
@@ -55,9 +53,8 @@ namespace Orchard.Packaging.Services {
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void ExtractFile(ExpandContext context, string relativePath) {
|
||||
#if REFACTORING
|
||||
Uri partUri = PackUriHelper.CreatePartUri(new Uri(context.SourcePath + relativePath, UriKind.Relative));
|
||||
PackagePart packagePart = context.Package.GetPart(partUri);
|
||||
using (Stream packageStream = packagePart.GetStream(FileMode.Open, FileAccess.Read)) {
|
||||
@@ -71,6 +68,7 @@ namespace Orchard.Packaging.Services {
|
||||
packageStream.CopyTo(fileStream);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void ExtractProjectFiles(ExpandContext context, params string[] itemGroupTypes) {
|
||||
@@ -113,16 +111,22 @@ namespace Orchard.Packaging.Services {
|
||||
}
|
||||
|
||||
private void ExtractThemeFiles(ExpandContext context) {
|
||||
#if REFACTORING
|
||||
foreach (var relativePath in from p in context.Package.GetParts()
|
||||
where p.Uri.ToString().StartsWith("/" + context.ExtensionName + "/", StringComparison.OrdinalIgnoreCase)
|
||||
select p.Uri.ToString().Substring(("/" + context.ExtensionName + "/").Length)) {
|
||||
ExtractFile(context, relativePath);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private bool PartExists(ExpandContext context, string relativePath) {
|
||||
#if REFACTORING
|
||||
Uri projectUri = PackUriHelper.CreatePartUri(new Uri(context.SourcePath + relativePath, UriKind.Relative));
|
||||
return context.Package.PartExists(projectUri);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +135,7 @@ namespace Orchard.Packaging.Services {
|
||||
}
|
||||
|
||||
private static bool LoadProject(ExpandContext context, string relativePath) {
|
||||
#if REFACTORING
|
||||
Uri projectUri = PackUriHelper.CreatePartUri(new Uri(context.SourcePath + relativePath, UriKind.Relative));
|
||||
if (!context.Package.PartExists(projectUri)) {
|
||||
return false;
|
||||
@@ -139,6 +144,7 @@ namespace Orchard.Packaging.Services {
|
||||
using (Stream stream = part.GetStream(FileMode.Open, FileAccess.Read)) {
|
||||
context.Project = XDocument.Load(stream);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -150,14 +156,19 @@ namespace Orchard.Packaging.Services {
|
||||
context.Stream = new MemoryStream();
|
||||
packageStream.CopyTo(context.Stream);
|
||||
}
|
||||
#if REFACTORING
|
||||
context.Package = Package.Open(context.Stream, FileMode.Open, FileAccess.Read);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void EndPackage(ExpandContext context) {
|
||||
#if REFACTORING
|
||||
context.Package.Close();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void GetCoreProperties(ExpandContext context) {
|
||||
#if REFACTORING
|
||||
context.ExtensionName = context.Package.PackageProperties.Identifier;
|
||||
context.ExtensionVersion = context.Package.PackageProperties.Version;
|
||||
|
||||
@@ -165,6 +176,7 @@ namespace Orchard.Packaging.Services {
|
||||
if (contentType.StartsWith(ContentTypePrefix)) {
|
||||
context.ExtensionType = contentType.Substring(ContentTypePrefix.Length);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void EstablishPaths(ExpandContext context, IVirtualPathProvider virtualPathProvider) {
|
||||
@@ -185,7 +197,7 @@ namespace Orchard.Packaging.Services {
|
||||
|
||||
private class ExpandContext {
|
||||
public Stream Stream { get; set; }
|
||||
public Package Package { get; set; }
|
||||
//public Package Package { get; set; }
|
||||
|
||||
public string ExtensionName { get; set; }
|
||||
public string ExtensionVersion { get; set; }
|
||||
|
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Packaging;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
@@ -57,6 +56,7 @@ namespace Orchard.Packaging.Services {
|
||||
}
|
||||
|
||||
public PackageData Download(string feedItemId) {
|
||||
#if REFACTORING
|
||||
PackagingEntry entry = _packagingSourceManager.GetModuleList().Single(x => x.SyndicationItem.Id == feedItemId);
|
||||
WebRequest request = WebRequest.Create(entry.PackageStreamUri);
|
||||
using (WebResponse response = request.GetResponse()) {
|
||||
@@ -76,6 +76,9 @@ namespace Orchard.Packaging.Services {
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
throw new NotImplementedException();
|
||||
#endif
|
||||
}
|
||||
|
||||
public PackageInfo Install(Stream packageStream) {
|
||||
|
@@ -23,7 +23,7 @@
|
||||
}
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.FeedUrl, T("Feed Url"))
|
||||
@Html.DropDownListFor(m => m.FeedUrl, new[]{new SelectListItem{Text=T("Download").ToString(),Value="Download"}}.Concat( Model.Sources.Select(x => new SelectListItem { Text = T("Push to {0}", x.FeedUrl).ToString(), Value = x.FeedUrl })))
|
||||
@Html.DropDownListFor(m => m.FeedUrl, new[]{new SelectListItem{Text=T("Download").ToString(),Value=""}}.Concat( Model.Sources.Select(x => new SelectListItem { Text = T("Push to {0}", x.FeedUrl).ToString(), Value = x.FeedUrl })))
|
||||
@Html.ValidationMessageFor(m=>m.FeedUrl)
|
||||
</fieldset>
|
||||
<input type="submit" value="Harvest" />
|
||||
|
@@ -93,6 +93,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Themes", "Orchard.Web\Theme
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.PublishLater", "Orchard.Web\Modules\Orchard.PublishLater\Orchard.PublishLater.csproj", "{C889167C-E52C-4A65-A419-224B3D1B957D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{104288A3-382E-4032-AF50-FBB5FDAB9EBB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuPack.Core", "..\external\nupack\NuPack.Core\NuPack.Core.csproj", "{F879F274-EFA0-4157-8404-33A19B4E6AEC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CodeCoverage|Any CPU = CodeCoverage|Any CPU
|
||||
@@ -492,6 +496,16 @@ Global
|
||||
{C889167C-E52C-4A65-A419-224B3D1B957D}.FxCop|Any CPU.Build.0 = Release|Any CPU
|
||||
{C889167C-E52C-4A65-A419-224B3D1B957D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C889167C-E52C-4A65-A419-224B3D1B957D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F879F274-EFA0-4157-8404-33A19B4E6AEC}.CodeCoverage|Any CPU.ActiveCfg = Coverage|Any CPU
|
||||
{F879F274-EFA0-4157-8404-33A19B4E6AEC}.CodeCoverage|Any CPU.Build.0 = Coverage|Any CPU
|
||||
{F879F274-EFA0-4157-8404-33A19B4E6AEC}.Coverage|Any CPU.ActiveCfg = Coverage|Any CPU
|
||||
{F879F274-EFA0-4157-8404-33A19B4E6AEC}.Coverage|Any CPU.Build.0 = Coverage|Any CPU
|
||||
{F879F274-EFA0-4157-8404-33A19B4E6AEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F879F274-EFA0-4157-8404-33A19B4E6AEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F879F274-EFA0-4157-8404-33A19B4E6AEC}.FxCop|Any CPU.ActiveCfg = Coverage|Any CPU
|
||||
{F879F274-EFA0-4157-8404-33A19B4E6AEC}.FxCop|Any CPU.Build.0 = Coverage|Any CPU
|
||||
{F879F274-EFA0-4157-8404-33A19B4E6AEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F879F274-EFA0-4157-8404-33A19B4E6AEC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -533,5 +547,6 @@ Global
|
||||
{8A4E42CE-79F8-4BE2-8B1E-A6B83432123B} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
||||
{0DFA2E10-96C8-4E05-BC10-B710B97ECCDE} = {383DBA32-4A3E-48D1-AAC3-75377A694452}
|
||||
{CB70A642-8CEC-4DDE-8C9F-AD08900EC98D} = {74492CBC-7201-417E-BC29-28B4C25A58B0}
|
||||
{F879F274-EFA0-4157-8404-33A19B4E6AEC} = {104288A3-382E-4032-AF50-FBB5FDAB9EBB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
Reference in New Issue
Block a user