在Orchard CMS的官网已经提供了文档说明如何打包,但是如果使用它的打包方式,打好的nuget包是带源代码的。如果是为开源系统写模块,不需要关注源代码是否可见。但是如果是用Orchard CMS作为商业用途,那么可能你需要阅读这边文章啦。
1.获取打包文件的原理:
简单说一下Orchard打包模块获取需要打包的文件的原理:控制台传入模块名称,通过找到对应模块的.csproj来分析需要打包的文件,每个.csproj中的ItemGroup节点下的文件就是需要打包的文件
所有的文件名和地址都封装成为IPackageFile,
最终使用NuGet的打包管理工具进行打包。
Orchard默认提供的打包程序都会把源代码打入包内,有时候我们需要不带源代码的NuGet包,所以就需要把Orchard.Package模块的PackageBuilder类改造一下下。
;
;
;
{
};
{
};
{
||
||
);
}
,
,
{
;
;
;
}
{
();
);
{
);
);
;
);
{
);
);
);
{
// 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
}