在Orchard CMS的官网已经提供了文档说明如何打包,但是如果使用它的打包方式,打好的nuget包是带源代码的。如果是为开源系统写模块,不需要关注源代码是否可见。但是如果是用Orchard CMS作为商业用途,那么可能你需要阅读这边文章啦。

1.获取打包文件的原理:

简单说一下Orchard打包模块获取需要打包的文件的原理:控制台传入模块名称,通过找到对应模块的.csproj来分析需要打包的文件,每个.csproj中的ItemGroup节点下的文件就是需要打包的文件

Orchard CMS中如何打包不带源码的模块

所有的文件名和地址都封装成为IPackageFile,

Orchard CMS中如何打包不带源码的模块

最终使用NuGet的打包管理工具进行打包。

Orchard默认提供的打包程序都会把源代码打入包内,有时候我们需要不带源代码的NuGet包,所以就需要把Orchard.Package模块的PackageBuilder类改造一下下。

public class PackageBuilder : IPackageBuilder {
;
;
;
{
};
{
};
{
||
||
);
}
,
,
{
;
;
;
}
{
();
);
{
);
);
;
);
{
);
);
);
{
// this is a simple theme with no csproj
);
}
}
{
);
}
{
);
}
;
}
{
;
}
{
);
);
;
;
);
{
);
}
}
{
Project
))
));
{
itemGroups
))
)
);
{
);
}
}
}
{
Project
))
))
))
{
),
))
})
);
{
);
// If it is not a core assembly
{
);
{
);
}
}
}
}
{
;
{
// ignore dlls, etc
{
;
}
// full virtual path given but we need the relative path so it can be put into
// the package that way (the package itself is the logical base path).
// Get it by stripping the basePath off including the slash.
);
);
}
}
{
);
}
{
();
();
}
{
;
{
;
;
}
{
;
;
}
}
{
;
{
));
;
}
;
}
{
(
,
);
);
}
{
);
}
#region Nested type: CreateContext
{
}
}
}
}
}
}
}
#endregion
#region Nested type: CreateContext
{
;
;
;
{
;
;
;
}
}
{
();
);
);
;
}
}
#endregion
}

相关文章:

  • 2021-05-07
  • 2021-05-25
  • 2021-10-17
  • 2021-08-09
  • 2022-12-23
  • 2021-12-22
  • 2022-02-13
  • 2022-12-23
猜你喜欢
  • 2021-06-24
  • 2022-02-14
  • 2022-03-04
  • 2021-09-06
相关资源
相似解决方案