在这里,我们将给大家分享关于asp.net–在Appharbor上的Dotless的知识,让您更了解asp.netapp_data的本质,同时也会涉及到如何更有效地.NETCoreApp3.1上的do
在这里,我们将给大家分享关于asp.net – 在Appharbor上的Dotless的知识,让您更了解asp.net app_data的本质,同时也会涉及到如何更有效地.NETCoreApp3.1上的dotnet pack导致错误的软件包、.Net异常:ASP.NET Core does not support multiple apps in the same app pool、Apache ShardingSphere 代码格式化实战 —— Spotless、ASP.NET MVC 4 – 应用程序不接受新连接字符串 – AppHarbor Deploy Issue的内容。
本文目录一览:- asp.net – 在Appharbor上的Dotless(asp.net app_data)
- .NETCoreApp3.1上的dotnet pack导致错误的软件包
- .Net异常:ASP.NET Core does not support multiple apps in the same app pool
- Apache ShardingSphere 代码格式化实战 —— Spotless
- ASP.NET MVC 4 – 应用程序不接受新连接字符串 – AppHarbor Deploy Issue
asp.net – 在Appharbor上的Dotless(asp.net app_data)
我已经确保文件是作为内容构建的,有一个mime类型,并且所有设置都是无点的.但它仍然没有工作……是否有其他人有同样的问题?有没有其他人能够解决它?
解决方法
.NETCoreApp3.1上的dotnet pack导致错误的软件包
如何解决.NETCoreApp3.1上的dotnet pack导致错误的软件包?
朋友
我迷路了,我正在尝试为.net core 3.1应用打包一个nuget程序包,但我不断收到错误的程序包。
我创建了一个示例方案,其中一个解决方案包含两个项目:
- Console1应用程序,.netcore3.1
- Console2应用程序,.netstandard2.0
Console1引用Console2。
我尝试为Console1创建一个nuget程序包,当我尝试将其安装在其他控制台上时,出现一个错误,提示Console2丢失并且找不到:
Severity Code Description Project File Line Suppression State
Error NU1101 Unable to find package ClassLibrary2. No packages exist with this id in source(s): Temp ConsoleApp7 C:\Users\xxx\source\repos\ConsoleApp7\ConsoleApp7\ConsoleApp7.csproj 1
然后,我将以下内容添加到项目文件中(在Google上阅读了一些内容):
<PropertyGroup> <TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);copyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
<Target Name="copyProjectReferencesToPackage" DependsOnTargets="BuildOnlySettings;ResolveReferences">
<ItemGroup>
<!-- Filter out unnecessary files -->
<_ReferencecopyLocalPaths Include="@(ReferencecopyLocalPaths->WithMetadataValue(''ReferenceSourceTarget'',''ProjectReference''))" />
</ItemGroup>
<!-- Print batches for debug purposes -->
<Message Text="Batch for .nupkg: ReferencecopyLocalPaths = @(_ReferencecopyLocalPaths),ReferencecopyLocalPaths.Destinationsubdirectory = %(_ReferencecopyLocalPaths.Destinationsubdirectory) Filename = %(_ReferencecopyLocalPaths.Filename) Extension = %(_ReferencecopyLocalPaths.Extension)" Condition="''@(_ReferencecopyLocalPaths)'' != ''''" />
<ItemGroup>
<!-- Add file to package with consideration of sub folder. If empty,the root folder is chosen. -->
<BuildOutputInPackage Include="@(_ReferencecopyLocalPaths)" TargetPath="%(_ReferencecopyLocalPaths.Destinationsubdirectory)" />
</ItemGroup>
</Target>
当我查看软件包时(使用软件包资源管理器),我现在看到nuget包含Console2的dll。但仍然-我遇到同样的错误。
我认为,如果dll存在,则依赖关系可能是一个问题,因此,我想也许我可以尝试看看是否可以以某种方式删除依赖关系,将PrivateAssets =“ all”添加到项目引用中,如下所示:
<ItemGroup>
<ProjectReference PrivateAssets="all" Include="..\ClassLibrary1\ClassLibrary1.csproj" />
</ItemGroup>
当我现在浏览该程序包时-我看到依存关系被移除了-仍然出现相同的错误。
这是什么,真的不可能为.netcoreapp3.1发布nuget软件包吗?
请帮助! 吉拉德
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
.Net异常:ASP.NET Core does not support multiple apps in the same app pool
阅文时长 | | 0.69分钟 | 字数统计 | | 1116字符 |
主要内容 | | 1、引言&背景 2、排查思路&解决方案 3、声明与参考资料 | ||
『.Net异常:ASP.NET Core does not support multiple apps in the same app pool』 | |||
编写人 | | SCscHero | 编写时间 | | 2022/2/5 PM4:16 |
文章类型 | | 系列 | 完成度 | | 已完成 |
座右铭 | 每一个伟大的事业,都有一个微不足道的开始。 |
一、引言&背景 完成度:100%
a) 应对问题
使用.Net5的WebAPI程序启动进入Swagger的Url,发现报了个:ASP.NET Core does not support multiple apps in the same app pool异常。详细异常如下:
HTTP Error 500.35 - ASP.NET Core does not support multiple apps in the same app pool
Common solutions to this issue:
Select a different app pool to host this app.
Specific error detected by ANCM:
Only one in-process application is allowed per IIS application pool. Please assign the application '/LM/W3SVC/3/ROOT/swagger/Index.html' to a different IIS application pool.
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft.com/fwlink/?LinkID=2028526
b) 应用场景
- 基于.Net技术站下的开发场景。
- 基于Visual Studio2019/2022的IDE下。
- 寄托于IIS的Debug下。
二、排查思路&解决方案 完成度:100%
a) 排查思路
- 结合异常提示以及查阅的资料,发现可能与IIS或VS的BUG有关。
1.1. 网上一种说法是IIS的App Pool被多个进程重复使用了。于是清理、重建、关闭了解决方案,再重启未果;尝试手动重启IIS App Pool办法,未果。
1.2. 看到网上一种说法,可能是和动了程序游览器启动设置和App Url有关(此前博主改动过App Url为swagger/Index.html),于是尝试改回去,仍是未果。 - 看到网上的一种说法是删除.vs下的文件即可恢复。我们知道.vs文件夹是一些个性化的设置,比如书签、断点设置等都记录在里面,如果全删势必影响较大。
2.1. 详见本章二节RootCause,删除指定文件。
b) 解决方案
【WorkAround】
不使用IIS的启动方式,使用.Net窗口方式启动。
【RootCause】
删除.vs[AppName]\config\applicationhost.config文件即可。本质原因尚未清晰,总之动了应用程序启动路由容易引发此问题。
三、声明与参考资料 完成度:100%
c# - HTTP Error 500.35 - ANCM Multiple In-Process Applications in same Process ASP.NET Core 3 - Stack Overflow
原创博文,未经许可请勿转载。
如有帮助,欢迎点赞、收藏、关注。如有问题,请评论留言!如需与博主联系的,直接博客私信SCscHero即可。
Apache ShardingSphere 代码格式化实战 —— Spotless
龙台,Apache ShardingSphere Contributor,GitHub 2.2K star hippo4j 作者,Github ID:longtai-cn。
为什么要代码格式化?代码格式化的意义是让代码更加 易读易懂易修改。
ShardingSphere 作为 Apache 顶级开源项目,截止当前已有 380+ 贡献者。因为大部分开发人员的代码风格不一致,在 Github 多人协作的模式下,不易保障项目整体代码格式。
基于以上诉求,ShardingSphere 采用了 Spotless 充当代码格式统一的角色。
什么是 Spotless
Spotless 是支持多种语言的代码格式化工具,支持 Maven 和 Gradle 以 Plugin 的形式构建。
Spotless 对开发者来说,有 2 种使用方式:检查代码是否存在格式问题,以及格式化代码。
ShardingSphere 采用 Maven 构建项目,以下若无特殊声明,Spotless 使用 Maven 做演示。
如何使用
下述代码是 Spotless 官方示例。
user@machine repo % mvn spotless:check [ERROR] > The following files had format violations: [ERROR] src\main\java\com\diffplug\gradle\spotless\FormatExtension.java [ERROR] -\t\t····if·(targets.length·==·0)·{ [ERROR] +\t\tif·(targets.length·==·0)·{ [ERROR] Run ''mvn spotless:apply'' to fix these violations. user@machine repo % mvn spotless:apply [INFO] BUILD SUCCESS user@machine repo % mvn spotless:check [INFO] BUILD SUCCESS
通过 mvn spotless:check
检查项目代码时发现错误,接着使用 mvn spotless:apply
进行代码格式化;再次检查时,格式化错误消失。
1. 项目实战
ShardingSphere 使用 Spotless 实现了添加 Java 文件 licenseHeader 和 Java 代码格式化。
Spotless 有多种 Java 代码格式化方式,例如:googleJavaFormat、eclipse、prettier 等。基于定制化的考虑,最终采用 eclipse 进行 Java 代码格式化。
1)根据项目需求添加 licenseHeader
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
注意,licenseHeader 最后要留有一行空格。不然 licenseHeader 和 package 之间将没有空隙。
2)添加 shardingsphere_eclipse_formatter.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ --> <profiles version="13"> <profile kind="CodeFormatterProfile" name="''ShardingSphere Apache Current''" version="13"> <setting id="org.eclipse.jdt.core.compiler.source" value="1.8"/> <setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8"/> <setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8"/> <setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="true"/> <setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/> <setting id="org.eclipse.jdt.core.formatter.lineSplit" value="200"/> <setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="200"/> <setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/> <setting id="org.eclipse.jdt.core.formatter.indentation.size" value="1"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/> <setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/> <setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="160"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="10"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="106"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="106"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="106"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call.count_dependent" value="16|5|80"/> </profile> </profiles>
ShardingSphere 最新规则查看 shardingsphere_eclipse_formatter.xml,另提供一份 eclipse-java-google-style.xml 供参考
shardingsphere_eclipse_formatter.xml 的内容是根据 ShardingSphere 代码规范定制开发的,可灵活变动。
3)添加 Maven plugin
<plugin> <groupId>com.diffplug.spotless</groupId> <artifactId>spotless-maven-plugin</artifactId> <version>2.22.1</version> <configuration> <java> <eclipse> <file>${maven.multiModuleProjectDirectory}/src/resources/shardingsphere_eclipse_formatter.xml</file> </eclipse> <licenseHeader> <file>${maven.multiModuleProjectDirectory}/src/resources/license-header</file> </licenseHeader> </java> </configuration> </plugin>
Spotless 支持格式化指定目录,以及排除指定目录的功能,详情参考 plugin-maven#java。如无指定,执行 check 或 apply 时,默认项目全量代码。
4)执行代码格式化
执行完上述三个步骤,就可以在项目中执行命令,检查 Java 代码是否符合规范,以及代码格式化功能。
user@machine repo % mvn spotless:apply [INFO] BUILD SUCCESS user@machine repo % mvn spotless:check [INFO] BUILD SUCCESS
2. 绑定 Maven 生命周期
在 ShardingSphere 实际应用中,选择将 Spotless apply 绑定到 compile 阶段,这样本地执行 mvn install 时就能自动格式化。
<plugin> <groupId>com.diffplug.spotless</groupId> <artifactId>spotless-maven-plugin</artifactId> <version>2.22.1</version> <configuration> <java> <eclipse> <file>${maven.multiModuleProjectDirectory}/src/resources/shardingsphere_eclipse_formatter.xml</file> </eclipse> <licenseHeader> <file>${maven.multiModuleProjectDirectory}/src/resources/license-header</file> </licenseHeader> </java> </configuration> <executions> <execution> <goals> <goal>apply</goal> </goals> <phase>compile</phase> </execution> </executions> </plugin>
3. IDEA 格式化
开发者如果在写代码过程中,想检查单个文件是否符合规范,执行 mvn spotless:check
或 mvn spotless:apply
显得有些笨重,因为格式化范围默认是整个项目。
我们可以使用 shardingsphere_eclipse_formatter.xml 替换 IntelliJ IDEA 原有格式化功能,这样在写代码过程中可以随时格式化,极大提升了开发效率。
IDEA 版本 2019.3.4。
1)安装插件 Eclipse Code Formatter
2)选择 shardingsphere_eclipse_formatter.xml 为默认格式化模板
使用 IDEA 代码格式化快捷键,就可以完成 Spotless 代码格式化。
常见问题
1. Spotless 与 Checkstyle 冲突
Checkstyle 是一种用于检查 Java 源代码是否符合代码标准或一组验证规则(最佳实践)的工具。
极端场景下,Spotless 格式化代码后,通过 Checkstyle 检查代码会不通过。
根本原因在于两者设定的检查配置和格式化配置冲突。举个例子,Spotless 格式化后换行缩进了 16 个空格,而 Checkstyle 的换行检查是 12 个空格。
private static Collection<PreciseHintShadowValue<Comparable<?>>> createNoteShadowValues(final ShadowDetermineCondition shadowDetermineCondition) { // Checkstyle 可以通过的格式 return shadowDetermineCondition.getSqlComments().stream().<PreciseHintShadowValue<Comparable<?>>>map( each -> new PreciseHintShadowValue<>(tableName, shadowOperationType, each)).collect(Collectors.toList()); // Spotless 格式化后 return shadowDetermineCondition.getSqlComments().stream().<PreciseHintShadowValue<Comparable<?>>>map( each -> new PreciseHintShadowValue<>(tableName, shadowOperationType, each)).collect(Collectors.toList()); }
这种情况,需要开发者衡量如何取舍。解决方案有两种:修改 Spotless 的格式化规则,或修改 Checkstyle 的检查规则。
2. CRLF 与 LF 格式化冲突
参考 https://github.com/diffplug/spotless/issues/1171
文末总结
文章介绍了 Apache ShardingSphere 使用 Spotless 完成历史代码格式化,以及后续代码格式的统一,对项目代码的整洁起到了很大帮助。
当然,Spotless 的功能不止 Java 代码的格式化,包括不限于 Pom 和 Markdown 等文件类型的格式化,后续这些都会在 ShardingSphere 得以应用。
欢迎点击链接,了解更多内容:
Apache ShardingSphere 官网:https://shardingsphere.apache.org/
Apache ShardingSphere GitHub 地址:https://github.com/apache/shardingsphere
SphereEx 官网:https://www.sphere-ex.com
欢迎添加社区经理微信(ss_assistant_1)加入交流群,与众多 ShardingSphere 爱好者一同交流。
ASP.NET MVC 4 – 应用程序不接受新连接字符串 – AppHarbor Deploy Issue
在构建我的类并设置连接字符串之后,我运行了我的项目,它为我生成了一个sql Server Express数据库,没有任何问题.
但问题是,我正在尝试部署到AppHarbor,我遇到连接字符串问题. AppHarbor要求您将sql Server安装为“附加组件”,并将连接字符串配置为具有将其Sequilizer连接字符串注入您从GitHub推送的项目的别名.
以下是他们的工作原理:http://support.appharbor.com/kb/add-ons/using-sequelizer
我相信我已正确完成所有这些设置,但我的应用程序如何读取连接字符串似乎存在问题.
这是我在本地计算机上使用的开发连接字符串:
<connectionStrings> <add name="DefaultConnection" connectionString="Data Source=.\sqlEXPRESS;Initial Catalog=aspnet-FranchiseManager-201275154247;Integrated Security=True" providerName="System.Data.sqlClient" /> </connectionStrings>
以下是AppHarbor Sequilizer连接字符串的样子:
<connectionStrings> <add name="DefaultConnection" connectionString="Server=0691298f-d461-40cc-86d6-a089016ba88d.sqlserver.sequelizer.com;Database=<removed hash value>;User ID=<removed hash value>;Password=<removed hash value>;" providerName="System.Data.sqlClient" /> </connectionStrings>
第一个连接 – 由我的EF本地生成 – 工作得很好.第二个 – 由Sequilizer创建 – 我的应用程序没有读取.
但是 – 我可以通过sql Server Management Studio连接到Sequilizer数据库.所以它一定是我的应用程序吗?
为了解决我的部署到AppHarbor的问题,我将他们的连接字符串硬编码到我的应用程序中,而不是由EF自动生成并在我的本地计算机上进行测试.
这是我做的:
>将Web.config中的连接字符串替换为一个AppHarbor
提供,
>清理解决方案,
>重建解决方案
但是当我运行应用程序时,它仍然使用EF生成的原始数据库 – 这必然意味着它仍然在读取旧的连接字符串.
似乎更改连接字符串是不够的.为了替换连接字符串,我应该更改应用程序中的其他内容?
任何建议表示赞赏 – 谢谢!
编辑
这是我的DbContext类:
public class FranchiseManagerContext : DbContext { public DbSet<FranchiseSet> FranchiseSets { get; set; } public DbSet<Franchise> Franchises { get; set; } }
这与名为“DefaultConnection”的连接字符串一样.
在这种情况下,EF如何知道DbContext与连接字符串匹配,但是如果更改字符串的名称,它就无法做到这一点?
UPDATE
我想我从这个答案中知道现在是什么:What is the point of “Initial Catalog” in a SQL Server connection string?
看起来初始目录属性指定了实体框架首次启动时要使用的特定数据库.
解决方法
MyAwesomeDatebase : DbContext
…然后实体框架将开箱即用:
<add name="MyAwesomeDatebase" connectionString="blah" providerName="System.Data.sqlClient" />
……但如果你有:
<add name="DefaultConnection" connectionString="blah" providerName="System.Data.sqlClient" />
…然后它将无法工作,因为实体框架无法知道MyAwesomeDatebase与DefaultConnection一起使用.
要做到这一点,请执行以下操作:
public class MyAwesomeDatebase : DbContext { public MyAwesomeDatebase() : base("DefaultConnection") }
……而你是金色的.
关于asp.net – 在Appharbor上的Dotless和asp.net app_data的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于.NETCoreApp3.1上的dotnet pack导致错误的软件包、.Net异常:ASP.NET Core does not support multiple apps in the same app pool、Apache ShardingSphere 代码格式化实战 —— Spotless、ASP.NET MVC 4 – 应用程序不接受新连接字符串 – AppHarbor Deploy Issue的相关知识,请在本站寻找。
本文标签: