zoukankan      html  css  js  c++  java
  • .NET5.0 MVC 生成发布(问题+技巧)

    问题:报错:Some services are not able to be constructed

    大概报错:Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: ITimetableService Lifetime: Scoped ImplementationType: TimetableService': Unable to resolve service for type 'IMicroAppService' while attempting to activate 'TimetableService'.)

    解析:TimetableService 构造函数中使用了 IMicroAppService 这个服务,构造时无法获取注入的 IMicroAppService 服务。

    原因:没有注入 IMicroAppService

    //startup.cs 的 ConfigureServices() 中添加
    services.AddScoped<IMicroAppService, MicroAppService>();
    

     

    项目生成时,将生成的内容(比如 dll)放到指定位置

    (reference:AlexanderYao 的 cmd的xcopy命令

    (reference:wnihil 的 回答

    右键项目 -> 属性 -> 生成事件 -> 生成后事件命令行

    输入以下命令

    xcopy "$(TargetDir)*.*" "$(SolutionDir)
    cm.WebHostModules$(ProjectName)" /E /Y /I
    

    命令解析:(以后再说……)

    .NET5.0、.NET Core 程序发布时,有些文件没有发布成功

    方法1、修改文件属性

    (reference:King、Wang 的 .Net core 应用程序发布Web时,有些文件夹没有发布成功解决办法

    右键点击没有发布成功的文件 -> 属性 -> 复制到输出目录 -> 如果较新则复制

    方法2、修改工程信息文件(.csproj 文件)

    添加如下内容:

      <ItemGroup>
        <None Update="Modules
    cm.Module.urp
    cm.Module.urp.dll">
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
      </ItemGroup>

  • 相关阅读:
    Java
    Java
    Java
    其他
    Java
    Java
    Java
    正则
    Win10
    【转】Flask 上下文机制和线程隔离
  • 原文地址:https://www.cnblogs.com/clis/p/14401398.html
Copyright © 2011-2022 走看看