anjoy8 / Blog.Core

💖 ASP.NET Core 8.0 全家桶教程,前后端分离后端接口,vue教程姊妹篇,官方文档:
http://apk.neters.club/.doc
Apache License 2.0
5.06k stars 1.38k forks source link

Blog.Core can't bulid in Mac? #237

Closed CatcherX closed 2 years ago

CatcherX commented 2 years ago

Bulid is mac, show: Users/xxxxx/Blog.Core/Blog.Core.Services/CSC: Error CS0006: Metadata file '/Users/xxxxx/Blog.Core/Blog.Core.Api/bin/Debug/net6.0/ref/Blog.Core.Repository.dll' could not be found (CS0006) (Blog.Core.Services)

run api project in terminal: dotnet run it show: ` **** Blog.Core Config Set ***** Current environment: Development Current authorization scheme: JWT Redis Caching AOP: False Memory Caching AOP: True Service Log AOP: False OPEN Log: IPLog ¡�RecordAccessLogs ¡� Transaction AOP: False DB Sql AOP To LogFile: False DB Sql AOP To Console: True SignalR send data: False IpRateLimiting: True MiniProfiler: False EnableAllIPs For CORS: False Redis MQ: False RabbitMQ: False Consul service: False EventBus: False Is multi-DataBase: False Is CQRS: False

**** Blog.Core DataBase Set ***** Is multi-DataBase: False Is CQRS: False

Master DB ConId: WMBLOG_SQLITE Master DB Type: Sqlite Master DB ConnectString: DataSource=/Users/xxxx/Blog.Core/Blog.Core.Api/WMBlog.db

Create Database(The Db Id:WMBLOG_SQLITE)... crit: Microsoft.AspNetCore.Hosting.Diagnostics[6] Application startup exception SqlSugar.SqlSugarException: English Message : Connection open error . The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception. Chinese Message : Á¬½�ý¾ݿ�³�з¢�´�£¬¼�·þ���·�£Á¬½�ַû´®�·�·£¬ʵ��²»µ½ԭ���Google´��Ϣ£ºThe type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.. at SqlSugar.Check.Exception(Boolean isException, String message, String[] args) at SqlSugar.SqliteProvider.get_Connection() at SqlSugar.AdoProvider.Dispose() at SqlSugar.SqlSugarProvider.Dispose() at SqlSugar.SqlSugarClient.Dispose() at SqlSugar.SqlSugarScope.Dispose() at Autofac.Core.Disposer.Dispose(Boolean disposing) at Autofac.Util.Disposable.Dispose() at Autofac.Core.Lifetime.LifetimeScope.Dispose(Boolean disposing) at Autofac.Util.Disposable.Dispose() at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.Dispose(Boolean disposing) at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.Dispose() at Autofac.Extensions.DependencyInjection.AutofacServiceScope.Dispose(Boolean disposing) at Autofac.Extensions.DependencyInjection.AutofacServiceScope.Dispose() at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder) at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>cDisplayClass4_0.b0(IApplicationBuilder builder) at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>cDisplayClass15_0.b1(IApplicationBuilder app) at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>cDisplayClass0_0.gMiddlewareFilterBuilder|0(IApplicationBuilder builder) at Microsoft.AspNetCore.HostFilteringStartupFilter.<>cDisplayClass0_0.b0(IApplicationBuilder app) at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken) Unhandled exception. SqlSugar.SqlSugarException: English Message : Connection open error . The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception. Chinese Message : 连接数据库过程中发生错误,检查服务器是否正常连接字符串是否正确,实在找不到原因请先Google错误信息:The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.. at SqlSugar.Check.Exception(Boolean isException, String message, String[] args) at SqlSugar.SqliteProvider.get_Connection() at SqlSugar.AdoProvider.Dispose() at SqlSugar.SqlSugarProvider.Dispose() at SqlSugar.SqlSugarClient.Dispose() at SqlSugar.SqlSugarScope.Dispose() at Autofac.Core.Disposer.Dispose(Boolean disposing) at Autofac.Util.Disposable.Dispose() at Autofac.Core.Lifetime.LifetimeScope.Dispose(Boolean disposing) at Autofac.Util.Disposable.Dispose() at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.Dispose(Boolean disposing) at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.Dispose() at Autofac.Extensions.DependencyInjection.AutofacServiceScope.Dispose(Boolean disposing) at Autofac.Extensions.DependencyInjection.AutofacServiceScope.Dispose() at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder) at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>cDisplayClass4_0.b0(IApplicationBuilder builder) at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>cDisplayClass15_0.b1(IApplicationBuilder app) at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>cDisplayClass0_0.gMiddlewareFilterBuilder|0(IApplicationBuilder builder) at Microsoft.AspNetCore.HostFilteringStartupFilter.<>cDisplayClass0_0.b0(IApplicationBuilder app) at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host) at Blog.Core.Program.Main(String[] args) in /Users/zwxue/Blog.Core/Blog.Core.Api/Program.cs:line 17 Gathering state for process 34442 Crashing thread 00b715d2 signal 00000006 Writing crash report to file /var/folders/79/0yxmkn155vl7cw5v98b_hyk80000gn/T/coredump.34442.crashreport.json Writing minidump with heap to file /var/folders/79/0yxmkn155vl7cw5v98b_hyk80000gn/T/coredump.34442 Written 1695465784 bytes (103483 pages) to core file Dump successfully written xxxx@m1 Blog.Core.Api % `

anjoy8 commented 2 years ago

mac电脑肯定是可以的。

1、首先你建一个官方的demo项目,看是否能正常跑; 2、检查/Users/xxxx/Blog.Core/Blog.Core.Api/WMBlog.db路径下是否有这个文件,同时看看是否有操作文件的权限。

CatcherX commented 2 years ago

1、demo is ok. https://github.com/liukuo362573/YiShaAdmin is also ok. 2、The File:/Users/xxxx/Blog.Core/Blog.Core.Api/WMBlog.db not found. How do I give it permission? The Mac is Apple M1,Visual Studio is 2019 or 2022.

Jamnine commented 2 years ago

检查下电脑.NET 版本,还有项目输出路径 /Users/xxxxx/Blog.Core/Blog.Core.Api/bin/Debug/net6.0/ref/Blog.Core.Repository.dll 这个路径看着有点问题 我直接拉取最新代码运行时没有出现这个问题 ,OS :mac 12.2 VS:Visual Studio 2022 for Mac version 17.0 Preview 5 Net vision : NET 6

e4ede85d35a00382f9627e64cebd28e 41919546261e12c3cdb3c8444c04e7c d241a4c7eb2db9442feb081fd326aec
CatcherX commented 2 years ago

@Jamnine My version: `xxxx@m1 ~ % dotnet --info .NET SDK (反映任何 global.json): Version: 6.0.102 Commit: 02d5242ed7

运行时环境: OS Name: Mac OS X OS Version: 12.0 OS Platform: Darwin RID: osx.12-arm64 Base Path: /usr/local/share/dotnet/sdk/6.0.102/

Host (useful for support): Version: 6.0.2 Commit: 839cdfb0ec

.NET SDKs installed: 6.0.102 [/usr/local/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download`

CatcherX commented 2 years ago

Visual Studio Community 2022 for Mac Preview Version 17.0 Preview (17.0 build 6509) Installation UUID: 99f3fc85-c1de-409d-a9b3-ff0b1e3c014f

Runtime .NET 6.0.2-servicing.1.22063.8 (64-bit) Architecture: Arm64

Roslyn (Language Service) 4.0.0-5.21501.19+8e1779e16298415843e85029d8b52a1ae9bb4c30

NuGet 版本: 6.0.0.262

.NET SDK (Arm64) SDK: /usr/local/share/dotnet/sdk/6.0.102/Sdks SDK 版本: 6.0.102 MSBuild SDK: /usr/local/share/dotnet/sdk/6.0.102/Sdks

.NET Core 运行时 运行时: /usr/local/share/dotnet/dotnet 运行时版本: 6.0.2

Xamarin.Profiler 未找到 '/Applications/Xamarin Profiler.app'

Updater 版本: 11

Apple Developer Tools A valid Xcode installation was not found at the configured location: '/Library/Developer/CommandLineTools'

Xamarin.Mac Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

Xamarin.iOS Xamarin.iOS not installed. Can't find mtouch or the Version file at /Library/Frameworks/Xamarin.iOS.framework/Versions/Current.

Xamarin Designer Version: 17.1.0.89 Hash: 4cdb8cdf9 Branch: remotes/origin/main Build date: 2022-01-21 12:52:18 UTC

Xamarin.Android 未安装

Microsoft Build of OpenJDK Java SDK: 未找到

Eclipse Temurin JDK Java SDK: 未找到

Android SDK Manager Version: 17.1.0.42 Hash: ad59eab Branch: remotes/origin/new/vsm-net6 Build date: 2022-01-21 12:52:23 UTC

Android Device Manager Information could not be retrieved

Build Information Release ID: 1700006509 Git revision: 9b49df492bf4110376bf57e7f03cd666a09079dc Build date: 2022-01-21 12:50:00+00 Build branch: release-17.0 Build lane: release-17.0

Operating System Mac OS X 12.0.1 Darwin 21.1.0 Darwin Kernel Version 21.1.0 Wed Oct 13 17:33:24 PDT 2021 root:xnu-8019.41.5~1/RELEASE_ARM64_T8101 arm64

Jamnine commented 2 years ago

你检查下你的代码文件夹权限,是否权限不足无法写入sqlite数据库文件?或者使用别的数据库进行连接,例如sqlserver

anjoy8 commented 2 years ago

作为问题排查,你可以直接下载sqlite的文件:https://img.neters.club/tool/WMBlog.db 拷贝到你的项目中,看是否可行。

/Users/xxxx/Blog.Core/Blog.Core.Api/WMBlog.db

如果能运行,证明你的mac电脑,不能正常生成db文件,你可以用mysql等其他db。

CatcherX commented 2 years ago

@anjoy8 两个问题: 1、解决方案生成失败,见顶楼的说明; 2、下载db文件,放到相应路径后,运行api项目,依然报错(明细如前所述);

anjoy8 commented 2 years ago

那你就换个数据库试试,比如mysql: image

CatcherX commented 2 years ago

@anjoy8 改用Mysql,可以成功运行。谢谢。