shou ye

.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)\ncm.WebHost\Modules\$(ProjectName)\" /E /Y /I

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

 

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

方法1、修改文件属性

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

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

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

添加如下内容:

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

 

posted @ 2021-02-14 00:38  芦荟柚子茶  阅读(606)  评论(0编辑  收藏  举报
ye jiao