上周它工作得很好!!!
现在,在下载并安装更新"15.8.2"后,当我尝试发布我的应用程序时,最后一步是失败的.我的意思是,虽然构建过程没有问题,但发布过程返回时出现以下错误:
"NETSDK1061:使用Microsoft.NETCore.App版本2.1.3恢复了该项目,但使用当前设置,将使用版本2.1.3-servicing-26724-03.要解决此问题,请确保使用相同的设置用于还原以及后续操作(如构建或发布).如果在构建或发布期间设置RuntimeIdentifier属性但在还原期间未设置,则通常会发生此问题.有关详细信息,请参阅https://aka.ms/dotnet-runtime-patch - 选择."
注意:如果我使用Vs2017(15.8.1)移动到另一台PC,一切都按预期工作.
请不要将此问题标记为重复,因为事实并非如此.我已经阅读了所有的帖子,博客和答案,但没有一个能给出真正的解决方案.我没有将任何软件包升级到2.1.2和2.1.3,我的所有软件包都引用了2.1.1,没有例外.我已经仔细检查了所有配置,一切似乎都没问题,我已经遵循了所有的指导原则,似乎没有什么是真正的解决方案.
注意:我的发布设置如下:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>73d9d7f6-a8ff-4543-99e0-6af66bba4509</ProjectGuid>
<publishUrl>bin\Release\netcoreapp2.1\publish\</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<TargetFramework>netcoreapp2.1</TargetFramework>
<SelfContained>false</SelfContained>
<_IsPortable>true</_IsPortable>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
如您所见,我的部署不是自包含的.它是框架依赖
我们的请求模型随着 API 日益复杂的增长而不断增长,我们决定使用复杂类型而不是使用简单类型作为操作参数。
一种典型的类型是IEnumerable逗号分隔值,例如我们使用https://www.strathweb.com/2017/07/customizing-query-string-parameter-bindingitems=1,2,3,5...中提供的解决方法解决了从字符串转换为 IEnumerable 的问题-in-asp-net-core-mvc/其中关键点是实现IActionModelConvention接口来识别标有特定属性的参数[CommaSeparated]。
一切工作正常,直到我们将简单参数移动到单个复杂参数中,现在我们无法检查实现中的复杂参数IActionModelConvention。使用时也会发生同样的情况IParameterModelConvention。请参阅下面的代码:
这工作正常:
public async Task<IActionResult> GetByIds(
[FromRoute]int day,
[BindRequired][FromQuery][CommaSeparated]IEnumerable<int> ids,
[FromQuery]string order)
{
// do something
}
Run Code Online (Sandbox Code Playgroud)
虽然这个变体不起作用
public class GetByIdsRequest
{
[FromRoute(Name = "day")]
public int Day { get; set; }
[BindRequired]
[FromQuery(Name = "ids")]
[CommaSeparated]
public IEnumerable<int> Ids { get; set; }
[FromQuery(Name = "order")]
public string Order { get; set; }
}
public async Task<IActionResult> GetByIds(GetByIdsRequest …Run Code Online (Sandbox Code Playgroud)