git提交或克隆报错fatal: unable to access ‘https://github.com/tata20191003/autowrite.git/‘: Failed to connec

1.问题原因 报错信息: fatal: unable to access ‘https://github.com/xxx/autowrite.git/’: OpenSSL SSL_read: Connection was reset, errno 10054 1 2 又或者 fatal: unable to access ‘https://github.com/xxx/autowrite.git/’: Failed to connect to github.com port 443: Timed out 1 2 因为git在拉取或者提交项目时,中间会有git的http和https代理,但是我们本地环境本身就有SSL协议了,所以取消git的https代理即可,不行再取消http的代理。 后续 原因还有一个,当前代理网速过慢,所以偶尔会成功,偶尔失败。 2.解决方案 1.在项目文件夹的命令行窗口执行下面代码,然后再git commit 或git clone 取消git本身的https代理,使用自己本机的代理,如果没有的话,其实默认还是用git的 //取消http代理 git config –global –unset http.proxy //取消https代理 git config –global –unset https.proxy 1 2 3 4 2.科学上网(vpn) 这样就能提高服务器连接速度,能从根本解决 time out 443问题 原文链接:https://blog.csdn.net/good_good_xiu/article/details/118567249

June 10, 2024

EF Add-Migration总结

EF CodeFirst对数据库任何的操作,千万不要手工去修改。 解释:add-migration命令是code first migration中的关键命令之一。当您对领域域模型进行更改并需要将它们时添加到数据库中,您将创建一个新的迁移。这是通过Add-Migration命令完成的。用最简单的形式,你只需要提供迁移名称 展现形式:命令将您的更改构建到一个cs文件中。这个cs文件与配置文件放在同一个文件夹中,服务于您要瞄准的DbContext 1.常用的命令: Add-Migration 、 Update-DataBase 、 Script-Migration (1)vs的程序包管理控制台输入 get-help Add-Migration -detailed以查看详细信息 Add-Migration [-Name] :指定自定义脚本 的名字 [-Force] [-ProjectName ] :如果要重新构建现有迁移,必须使用-Force参数。然而,只有在迁移尚未应用到数据库时,才能重新构建框架。否则你 需要回复到要重新构建的迁移之前的迁移 [-StartUpProjectName ] :是从 解决方案资源管理器中选择一个项目 作为启动项目。如果我们忽略的话,就会默认为解决方案资源管理器中的启动项目。 [-ConfigurationTypeName ] :项目中有多个DbContext,那么您需要指出哪个数据库会更新。这可以用-ConfigurationTypeName做。ConfigurationTypeName方法是迁移文件夹中配置类的名称。 [-ConnectionStringName ] :从应用程序的配置文件中指定要使用的连接字符串的名字。我们用两个参数-ConnectionString -ConnectionProviderName ,或者用这样一个参数代替 [-IgnoreChanges] :假设目标数据库模式与当前的模型是一致的。构建一个空迁移和对应的空的迁移文件,忽略在当前模型中检测到的任何挂起的更改。可用于创建初始的空迁移,以支持对现有数据库的迁移。 [-AppDomainBaseDirectory ]:指定用于运行数据迁移代码的app-domain的路径,从而app-domain 可以找到所有需要的程序集。这是一个高级选项,只有当解决方案包含多个项目时才会需要。这样的话,context和configuration所需要的程序集就不仅仅从那些包含context和包含migrations的项目中获取 CommonParameters Add-Migration (你的迁移文件名称) 若在一个项目里,操作多个DbConext的方法则需要指定context名称 add-migration 迁移名称 -c ConfigurationDbContext update-database -c ConfigurationDbContext

June 8, 2024

MediatR Official Document

MediatR is a low-ambition library trying to solve a simple problem — decoupling the in-process sending of messages from handling messages. Cross-platform, supporting netstandard2.0. Setup Install the package via NuGet first: Install-Package MediatR MediatR directly references Microsoft.Extensions.DependencyInjection.Abstractions leveraging IServiceProvider. Typical usage is to use IServiceCollection directly: services.AddMediatR(cfg => { cfg.RegisterServicesFromAssembly(typeof(Program).Assembly); }); This method registers the known MediatR types: IMediator as transient ISender as transient IPublisher as transient For each assembly registered, the AddMediatR method will scan those assemblies for MediatR types (excluding behaviors): ...

June 5, 2024

MSBuild介绍

Microsoft 生成引擎是一个用于生成应用程序的平台。 此引擎(也称为 MSBuild)为项目文件提供了一个 XML 架构,用于控制生成平台处理和生成软件的方式。 Visual Studio 会使用 MSBuild,但 MSBuild 不依赖于 Visual Studio。 通过在项目或解决方案文件中调用 msbuild.exe 或 dotnet build,可以在未安装 Visual Studio 的环境中安排和生成产品。 Visual Studio 使用 MSBuild 来加载和生成托管项目。 Visual Studio 中的项目文件(.csproj、.vbproj、vcxproj 等)包含 MSBuild XML 代码,当你使用 IDE 来生成项目时,此代码就会运行。 Visual Studio 项目会导入所有必要的设置和生成过程来执行典型的开发工作,但你可以从 Visual Studio 内或通过使用 XML 编辑器对其进行扩展或修改。 若要在没有 Visual Studio 的 Windows 系统上安装 MSBuild,请转到下载页面上的 Visual Studio 生成工具。 通过此方法安装 MSBuild 可获得 MSBuild.exe。 对于 .NET Core 和 .NET 5 或更高版本,获取 MSBuild 等效项的另一种方法是安装 .NET SDK。 .NET 生成命令 dotnet build 可与 macOS、Windows 或 Linux 上的 .NET SDK 一起使用。 .NET 生成命令 dotnet build 是 .NET Core 版本 MSBuild.exe 的精简包装器。 可以使用 .NET Core 命令行接口 (CLI)(使用 MSBuild)来生成面向 .NET Core 和 .NET 5 及更高版本的项目。 ...

June 4, 2024

NSwag 和 ASP.NET Core 入门

NSwag 提供了下列功能: 能够使用 Swagger UI 和 Swagger 生成器。 灵活的代码生成功能。 借助 NSwag,无需使用现有 API。也就是说,可使用包含 Swagger 的第三方 API,并生成客户端实现。 使用 NSwag,可以加快开发周期,并轻松适应 API 更改。 包安装 将 NSwag 安装到: 生成已实现的 Web API 的 Swagger 规范。 为 Swagger UI 提供服务以浏览和测试 Web API。 为 Redoc 提供服务,以为 Web API 添加 API 文档。 若要使用 NSwag ASP.NET Core 中间件,请安装 NSwag.AspNetCore NuGet 包。 此包内的中间件可用于生成并提供Swagger 规范、Swagger UI(v2 和 v3)和 ReDoc UI。 NSwag 14 仅支持 v3 版的 Swagger UI 规范。 若要安装 NSwag NuGet 包,请使用以下方法之一: ...

June 4, 2024

NSwag.MSBuild使用

Package: NSwag.MSBuild Important for .NET Core: Assembly loading#net-core After installing the NSwag.MSBuild NuGet package in your project, you can use the variable $(NSwagExe) in your .csproj file to run the NSwag command line tool in an MSBuild target. This way the tools can easily be updated via NuGet. The /controller parameter can be omitted to generate a Swagger specification for all controllers. For better testability and stable output (defaults may change), it is recommended to create an NSwag Configuration Document (e.g. with NSwagStudio) and use: ...

June 4, 2024

关于MSBuild和NSwag的深入学习

这段时间学习一个整洁架构的开源项目,这是一名澳大利亚的软件架构师在github上面分享的项目:https://github.com/jasontaylordev/CleanArchitecture 作者的架构根底扎实,而且能灵活运用各种最新最简洁的技术知识,这个项目就用到非常多,我把代码pull下来之后发现直接编译过程中出了不少错误,花了两天时间都解决了。其中很大一部分是关于前端项目的内容,作者直接使用MSBuild来完成打包和创建,这只是我第一次看到。 另外还通过NSwag.MSBuild完成Open API代码的生成和typescript代码生成(运用于Angular),其中一个让我很惊讶的是:他居然在项目编译的时候初始化了数据库,弄得我云里雾里。我修改连接字符串,从报错信息才知道是执行这部分脚本的时候,MSWage的内核里初始化了Core的项目,调用到了初始化数据库代码: Executing file ‘config.nswag’ with variables ‘Configuration=Debug’… C:\Users\csuma.nuget\packages\nswag.msbuild\14.0.7\tools\Net80 下面是报错信息: Error NSwag command line tool for .NET Core Net80, toolchain v14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0));Visit http://NSwag.org for more information.;NSwag bin directory: C:\Users\csuma.nuget\packages\nswag.msbuild\14.0.7\tools\Net80;Executing file ‘config.nswag’ with variables ‘Configuration=Debug’…;Launcher directory: C:\Users\csuma.nuget\packages\nswag.msbuild\14.0.7\tools\Net80;fail: CleanArchitecture.Infrastructure.Data.ApplicationDbContextInitialiser[0];An error occurred while initialising the database.;Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.<>cDisplayClass20_0.<b0>d.MoveNext();— End of stack trace from previous location —;at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.<>cDisplayClass20_0.<b0>d.MoveNext();— End of stack trace from previous location —;at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func4 verifySucceeded, CancellationToken cancellationToken);at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.ExistsAsync(CancellationToken cancellationToken);at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.MigrateAsync(String targetMigration, CancellationToken cancellationToken);at CleanArchitecture.Infrastructure.Data.ApplicationDbContextInitialiser.InitialiseAsync() in D:\project\CleanArchitecture\CleanArchitecture-main\CleanArchitecture-main\src\Infrastructure\Data\ApplicationDbContextInitialiser.cs:line 46;at CleanArchitecture.Infrastructure.Data.InitialiserExtensions.InitialiseDatabaseAsync(WebApplication app) in D:\project\CleanArchitecture\CleanArchitecture-main\CleanArchitecture-main\src\Infrastructure\Data\ApplicationDbContextInitialiser.cs:line 21;at Program. ...

June 4, 2024

命令行执行NSwag

Important for .NET Core: Assembly loading#net-core To use the command line tool nswag.exe (.NET 4.6+) / dotnet-nswag.dll (.NET Core), choose one of the following methods: NSwag NPM Module: Bindings for the .NET 4.6+ and .NET Core command line tools (depending on installed framework/OS platform) Download latest NSwagStudio MSI installer or install package NSwagStudio via Chocolatey: After installing the application, the path to the nswag.exe binary is registered in the PATH variable so that the tool can be used in the Windows command line. Download the latest command line tools: Extract the ZIP archive and use the nswag.exe binary in the Windows command line. NSwag.MSBuild NuGet package To see all available commands and parameters, run the command line application “nswag.exe” without parameters and enter “help” as command. All “input” parameters accept file paths, URLs and JSON data. ...

June 4, 2024

解决ng : 无法将“ng”项识别为 cmdlet、函数、脚本文件或可运行程序的名称及ng : 无法加载文件npm g.ps1问题

解决ng : 无法将“ng”项识别为 cmdlet、函数、脚本文件或可运行程序的名称 及 ng : 无法加载文件 C:\Users\15762\AppData\Roaming\npm\ng.ps1问题 ng : 无法将“ng”项识别为 cmdlet、函数、脚本文件或可运行程序的名称 解决 在命令行执行npm install -g @angular/cli ng : 无法加载文件 C:\Users\15762\AppData\Roaming\npm\ng.ps1 解决 以管理员身份运行Windows PowerShell,输入set-ExecutionPolicy RemoteSigned 选择是选择 A ng : 无法将“ng”项识别为 cmdlet、函数、脚本文件或可运行程序的名称 解决 在命令行执行npm install -g @angular/cli ng : 无法加载文件 C:\Users\15762\AppData\Roaming\npm\ng.ps1 解决 以管理员身份运行Windows PowerShell,输入set-ExecutionPolicy RemoteSigned 选择是选择 A

June 3, 2024

使用Visual Studio 2022 中的 .http 文件, ASP.NET Core API快速测试

Visual Studio 2022.http 文件编辑器提供了一种便捷的方式来测试 ASP.NET Core项目,尤其是 API 应用。 编辑器提供一个 UI,用于: 创建和更新 .http 文件。 发送 .http 文件中指定的 HTTP 请求。 显示响应。 本文包含以下文档: .http 文件语法。 如何创建 .http 文件。 如何从 .http 文件发送请求。 在何处查找可配置的 .http 文件选项。 如何使用 Visual Studio 2022 终结点资源管理器在 .http 文件中创建请求。 .http 文件格式和编辑器受 Visual Studio Code REST 客户端扩展的启发。 Visual Studio 2022 .http 编辑器将 .rest 识别为相同文件格式的替代文件扩展名。 先决条件 安装了“ASP.NET 和 Web 部署”工作负载的 Visual Studio 2022 版本 17.8 或更高版本。 .http 文件语法 以下部分介绍 .http 文件语法。 请求 HTTP 请求的格式为 HTTPMethod URL HTTPVersion,全部在一行上,其中: ...

June 1, 2024