When creating a nupkg file, don’t include assemblies that are part of the Orchard Frx (e.g. System.Web.Mvc.dll)

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2011-03-22 11:34:56 -07:00
parent f1353e428a
commit e65709a3a2
4 changed files with 28 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ using System.Net.Mime;
using System.Reflection;
using System.Xml.Linq;
using NuGet;
using Orchard.Environment;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Models;
using Orchard.FileSystems.VirtualPath;
@@ -18,6 +19,7 @@ namespace Orchard.Packaging.Services {
public class PackageBuilder : IPackageBuilder {
private readonly IWebSiteFolder _webSiteFolder;
private readonly IVirtualPathProvider _virtualPathProvider;
private readonly IOrchardFrameworkAssemblies _frameworkAssemblies;
private static readonly string[] _ignoredThemeExtensions = new[] {
"obj", "pdb", "exclude"
@@ -34,9 +36,12 @@ namespace Orchard.Packaging.Services {
}
public PackageBuilder(IWebSiteFolder webSiteFolder,
IVirtualPathProvider virtualPathProvider) {
IVirtualPathProvider virtualPathProvider,
IOrchardFrameworkAssemblies frameworkAssemblies) {
_webSiteFolder = webSiteFolder;
_virtualPathProvider = virtualPathProvider;
_frameworkAssemblies = frameworkAssemblies;
}
public Stream BuildPackage(ExtensionDescriptor extensionDescriptor) {
@@ -112,10 +117,14 @@ namespace Orchard.Packaging.Services {
foreach (var entry in entries) {
var assemblyName = new AssemblyName(entry.Include.Value);
string virtualPath = _virtualPathProvider.GetReferenceVirtualPath(context.SourcePath, assemblyName.Name, entry.HintPath != null ? entry.HintPath.Value : null);
if (!string.IsNullOrEmpty(virtualPath)) {
EmbedVirtualFile(context, virtualPath, MediaTypeNames.Application.Octet);
// If it is not a core assembly
if (_frameworkAssemblies.GetFrameworkAssemblies().FirstOrDefault(assembly => assembly.FullName.Equals(assemblyName.FullName)) == null) {
string virtualPath = _virtualPathProvider.GetReferenceVirtualPath(context.SourcePath, assemblyName.Name, entry.HintPath != null ? entry.HintPath.Value : null);
if (!string.IsNullOrEmpty(virtualPath)) {
EmbedVirtualFile(context, virtualPath, MediaTypeNames.Application.Octet);
}
}
}
}

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
using System.Reflection;
namespace Orchard.Environment {
public interface IOrchardFrameworkAssemblies : IDependency {
IEnumerable<AssemblyName> GetFrameworkAssemblies();
}
public class DefaultOrchardFrameworkAssemblies : IOrchardFrameworkAssemblies {
public IEnumerable<AssemblyName> GetFrameworkAssemblies() {
return typeof (IDependency).Assembly.GetReferencedAssemblies();
}
}
}

View File

@@ -7,7 +7,6 @@ using System.Web.WebPages.Razor;
using Orchard.Environment;
using Orchard.Environment.Extensions.Loaders;
using Orchard.FileSystems.Dependencies;
using Orchard.FileSystems.VirtualPath;
namespace Orchard.Mvc.ViewEngines.Razor {
public interface IRazorCompilationEvents {

View File

@@ -185,6 +185,7 @@
<Compile Include="Environment\Features\FeatureManager.cs" />
<Compile Include="Environment\IAssemblyLoader.cs" />
<Compile Include="Environment\HostComponentsConfigModule.cs" />
<Compile Include="Environment\IOrchardFrameworkAssemblies.cs" />
<Compile Include="Environment\ViewsBackgroundCompilation.cs" />
<Compile Include="Environment\Warmup\StartupResult.cs" />
<Compile Include="Environment\Warmup\WarmupUtility.cs" />