【问题标题】:How to Properly Reference Assemblies in DNN Manifest?如何在 DNN Manifest 中正确引用程序集?
【发布时间】:2019-09-05 01:51:22
【问题描述】:

我正在使用 ASP.NET MVC 编写一个 DNN 9 自定义模块。我的开发站点设置在 dnndev.me,模块位于 C:\websites\dnndev.me\DesktopModules\MVC|MyModule

我的 DNN 清单如下:

<dotnetnuke type="Package" version="5.0">
<packages>
<package name="Onboarding" type="Module" version="00.00.05">
  <friendlyName>Onboarding</friendlyName>
  <description>Onboarding</description>
  <iconFile>~/Icons/Sigma/Software_32X32_Standard.png</iconFile>
  <owner>
    <name>example.com</name>
    <organization>example.com</organization>
    <url>https://example.com/</url>
    <email>info@example.com</email>
  </owner>
  <license src="License.txt"></license>
  <releaseNotes src="ReleaseNotes.txt"></releaseNotes>
  <dependencies>
    <dependency type="CoreVersion">08.00.00</dependency>
  </dependencies>
  <components>
    <component type="Script">
      <scripts>
        <basePath>DesktopModules\MVC\MyModule</basePath>
        <script type="Install">
          <path>Providers\DataProviders\SqlDataProvider</path>
          <name>00.00.01.SqlDataProvider</name>
          <version>00.00.01</version>
        </script>
        <script type="UnInstall">
          <path>Providers\DataProviders\SqlDataProvider</path>
          <name>Uninstall.SqlDataProvider</name>
          <version>00.00.01</version>
        </script>
      </scripts>
    </component>
    <component type="ResourceFile">
      <resourceFiles>
        <basePath>DesktopModules/MVC/MyModule</basePath>
        <resourceFile>
          <name>Resources.zip</name>
        </resourceFile>
      </resourceFiles>
    </component>
    <component type="Module">
      <desktopModule>
        <moduleName>Onboarding</moduleName>
        <foldername>Onboarding</foldername>
        <businessControllerClass>MySite.Modules.Onboarding.Components.FeatureController</businessControllerClass>
        <supportedFeatures />
        <moduleDefinitions>
          <moduleDefinition>
            <friendlyName>Onboarding</friendlyName>
            <defaultCacheTime>0</defaultCacheTime>
            <moduleControls>
              <moduleControl>
                <controlKey />
                <controlSrc>Example.Modules.Onboarding.Controllers/Onboarding/Index.mvc</controlSrc>
                <supportsPartialRendering>False</supportsPartialRendering>
                <controlTitle />
                <controlType>View</controlType>
                <iconFile />
                <helpUrl />
                <viewOrder>0</viewOrder>
              </moduleControl>
              <moduleControl>
                <controlKey>Edit</controlKey>
                <controlSrc>Example.Modules.Onboarding.Controllers/Onboarding/Edit.mvc</controlSrc>
                <supportsPartialRendering>False</supportsPartialRendering>
                <controlTitle>Edit Onboarding Records</controlTitle>
                <controlType>Edit</controlType>
                <iconFile />
                <helpUrl />
                <viewOrder>0</viewOrder>
                <supportsPopUps>True</supportsPopUps>
              </moduleControl>
              <moduleControl>
                <controlKey>Settings</controlKey>
                <controlSrc>Example.Modules.Onboarding.Controllers/Settings/Settings.mvc</controlSrc>
                <supportsPartialRendering>False</supportsPartialRendering>
                <controlTitle>Onboarding Settings</controlTitle>
                <controlType>Edit</controlType>
                <iconFile />
                <helpUrl />
                <viewOrder>0</viewOrder>
              </moduleControl>
            </moduleControls>
          </moduleDefinition>
        </moduleDefinitions>
      </desktopModule>
    </component>
    <component type="Assembly">
      <assemblies>
        <assembly>
          <name>Onboarding.dll</name>
          <path>bin</path>
        </assembly>
        <assembly>
          <name>RestSharp.dll</name>
          <path>bin</path>
        </assembly>
        <assembly>
          <name>EntityFramework.dll</name>
          <path>bin</path>
        </assembly>
        <assembly>
          <name>EntityFramework.SqlServer.dll</name>
          <path>bin</path>
        </assembly>
        <assembly>
          <name>Newtonsoft.Json.dll</name>
          <path>bin</path>
        </assembly>
      </assemblies>
    </component>
  </components>
</package>

尽管确保所有程序集都在 dnndev.me 下的 bin 文件夹中,但模块不会安装。

我必须做些什么来纠正这个问题?

【问题讨论】:

  • 您使用的是 Chris Hammond 的 MVC 模块开发模板吗?如果是这样,当您进行发布构建以创建包时,是否将这些依赖项放入 zip 包中的 /bin 文件夹中?
  • @DotNetNuclear 是的,我正在使用他的开发模板。依赖项/程序集未放置在安装 zip 文件中的 bin 文件夹中。我想我需要按照建议使用依赖类型=“类型”。将进一步更新。

标签: dotnetnuke


【解决方案1】:

如果您使用 Chris Hammond 模板构建 MVC 模块,您将拥有用于打包由文件驱动的模块的 msbuild 过程:BuildScripts/ModulePackage.targets

在那个文件中,有一行代码:

<Copy SourceFiles="$(MSBuildDnnBinPath)\$(AssemblyName).dll" DestinationFolder="$(MSBuildProjectDirectory)\Package\bin"/>

它负责在本地安装的 bin 文件夹中提取模块的程序集,并将其复制到压缩的包文件夹中。没有用于在其中包含其他自定义 dll 的自动步骤。此行出现两次:一次用于“源”包,另一行用于“安装”包。

大多数时候,我只会更新此脚本以包含我的依赖项。示例:

<Copy SourceFiles="$(MSBuildDnnBinPath)\$(AssemblyName).dll" DestinationFolder="$(MSBuildProjectDirectory)\Package\bin"/>
<Copy SourceFiles="$(MSBuildDnnBinPath)\Onboarding.dll" DestinationFolder="$(MSBuildProjectDirectory)\Package\bin"/>

这不是最优雅的解决方案,因为您需要在构建脚本中硬编码您的依赖项。但它适用于简单的模块。如果您对 msbuild 有一点了解,则可以使用复制步骤,将所有 dll 包含在一个文件夹中,并将您的依赖项移动到一个文件夹中,并从该文件夹中包含所有这些。

【讨论】:

    【解决方案2】:

    您这样做的方式意味着程序集包含在您的安装包中。要测试是否安装了程序集(在 bin 文件夹中),您需要添加一个依赖项,但对于包含版本号或类似内容的程序集没有依赖项。诀窍是向程序集中定义的类型添加依赖项,例如

    <dependency type="Type">DocumentFormat.OpenXml.Extensions.WorksheetWriter</dependency>
    

    AFAIR 重要的是 type 属性的值区分大小写,因此它必须是“Type”,而不是“type”或“TYPE”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-18
      • 2022-01-20
      • 1970-01-01
      • 2019-06-08
      • 1970-01-01
      • 1970-01-01
      • 2011-04-04
      • 2014-09-14
      相关资源
      最近更新 更多