我需要使用Azure Devops将Asp.Net核心应用程序部署到Azure WebApp。
我有以下工作的Azure-Pipelines YAML文件:
trigger:
- master
variables:
buildConfiguration: 'Release'
buildPlatform: 'any cpu'
version: '0.2.0'
stages:
- stage: 'Stage1'
jobs:
# Previous Jobs like Build, Test, ...
- job: 'Publish'
pool:
vmImage: 'Ubuntu-16.04'
dependsOn: 'Test'
steps:
- task: DotNetCoreCLI@2
displayName: 'Publish'
inputs:
command: publish
publishWebProjects: false
projects: '**/*.csproj'
arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
zipAfterPublish: true
- task: PublishBuildArtifacts@1
displayName: 'Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
- task: AzureRmWebAppDeployment@4
displayName: 'Deploy'
inputs:
package: '$(build.artifactstagingdirectory)/App.Api.zip'
azureSubscription: 'MyName.Azure'
appType: 'Web App On Windows'
webAppName: …
Run Code Online (Sandbox Code Playgroud) 我有以下 Angular 7 形式:
ngOnInit() {
this.organizationId = 1; // Used for testing
this.form = this.formBuilder.group({
name: [''],
organizationId: [{ value: this.organizationId, disabled: this.enableOrganizationChange }],
start: ['']
});
}
Run Code Online (Sandbox Code Playgroud)
在 HTML 中我使用的是Select
for OrganizationId
。它按预期被禁用。
然而,提交时该值null
不是 1:
onSubmit() {
if (this.form.valid) {
this.submitting = true;
console.log(this.form.value.organizationId);
let request: Request = {
name: this.form.value.name,
organizationId: this.form.value.organizationId.value,
start: this.form.value.start
};
}
}
Run Code Online (Sandbox Code Playgroud)
为什么记录的值是null
而不是1
?
我使用禁用只是为了避免用户更改值。
但我仍然需要提交时的值...
我在 Angular 组件上有以下可观察的内容:
count$: Observable<number>;
this.count$ = this.getCount();
Run Code Online (Sandbox Code Playgroud)
通过使用以下内容,我得到值 0(零);
this.count$.subscribe(x => console.log(x));
Run Code Online (Sandbox Code Playgroud)
在模板上我有:
<a routerLink="/dash" *ngIf="(count$ | async)">
<ng-container *ngIf="count$ | async as count">
Count: {{count}}
</ng-container>
</a>
Run Code Online (Sandbox Code Playgroud)
如果count$
是 1,我得到Count: 1
,但如果count$
是 0,内容Count: 0
甚至不会呈现。
知道为什么吗?
在 ASP.NET Core 2.2 控制器上,我有以下内容:
var principal = this.User as ClaimsPrincipal;
var authenticated = this.User.Identity.IsAuthenticated;
var claims = this.User.Identities.FirstOrDefault().Claims;
var id = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
Run Code Online (Sandbox Code Playgroud)
我能够检查用户是否是authenticated
并获取claims
包括id
.
我怎么能Controller
在我没有的地方之外做同样的事情this.User
?
我正在尝试在 Azure 中托管 ASP.NET Core 3.0 API:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<IsPackable>false</IsPackable>
<NeutralLanguage>en-US</NeutralLanguage>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.*" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.*" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.*" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.*" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
但是当我运行 de application 时,我得到:
HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
Specific error detected by ANCM:
It was not possible to find any compatible framework version …
Run Code Online (Sandbox Code Playgroud) 我在 ASP.NET Core 3.1 csproj 文件中有以下内容:
<ItemGroup>
<Content Include="webroot\**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Target Name="Approot" BeforeTargets="BeforeBuild;BeforePublish">
<Exec WorkingDirectory="approot" Command="npm install" />
<Exec WorkingDirectory="approot" Command="npm run build --prod" />
</Target>
Run Code Online (Sandbox Code Playgroud)
我正在approot
文件夹中构建客户端应用程序并将结果保存到 webroot 文件夹。
我需要将 webfoot 文件夹复制到输出目录...
问题
当我构建它时,文件被放置在 webfoot 文件夹中,但它没有被复制到输出中。
所以我需要再次重建它,以便将 webroot 文件夹复制到输出...
似乎在构建之后运行了 2 个 npm 命令,但我使用的是 BeforeBuild。
我在 ASP.NET Core 3.1 项目上有以下 Identity Server 4 配置:
services
.AddIdentityServer(y => {
y.Events.RaiseErrorEvents = true;
y.Events.RaiseInformationEvents = true;
y.Events.RaiseFailureEvents = true;
y.Events.RaiseSuccessEvents = true;
})
.AddDeveloperSigningCredential()
.AddInMemoryPersistedGrants()
.AddInMemoryIdentityResources(Config.IdentityResources())
.AddInMemoryApiResources(Config.ApiResources())
.AddInMemoryApiScopes(Config.GetApiScopes())
.AddInMemoryClients(Config.Clients)
.AddProfileService<ProfileService>()
.AddAspNetIdentity<User>();
Run Code Online (Sandbox Code Playgroud)
该Config
如下:
public static class Config {
public static List<ApiResource> ApiResources() {
return new List<ApiResource> {
new ApiResource("api", "API Resource")
};
}
public static List<ApiScope> ApiScopes() {
return new List<ApiScope> {
new ApiScope("api", "API Scope")
};
}
public static List<IdentityResource> IdentityResources() {
return new List<IdentityResource> …
Run Code Online (Sandbox Code Playgroud) 我将项目更新到 NetCore 6,但收到警告:
Converting null literal or possible null value to non-nullable type.
Run Code Online (Sandbox Code Playgroud)
例如在单元测试中:
String source = null;
String expect = null;
String actual = source.ToSafeBase64Url();
Run Code Online (Sandbox Code Playgroud)
我在代码的多个地方收到此警告。
我应该如何解决这个问题?
使用 NET 6 我有以下项目结构:
nuget.config
project.code-workspace
- Core
Core.csproj
- Api
Api.csproj
- Sim
notebook.ipynb
Run Code Online (Sandbox Code Playgroud)
notebook.ipynb
现在在哪里:
#i "nuget:https://api.nuget.org/v3/index.json"
#r "nuget:Microsoft.Data.Analysis,0.*"
using System;
using Microsoft.Data.Analysis;
Console.WriteLine("Hello World!");
Run Code Online (Sandbox Code Playgroud)
如何在 中包含对 Core 和 Api 项目的项目引用notebook.ipynb
?
我需要使用notebook.ipynb
.
我有以下示例代码:
Context context = new Context();
Repository repository = new Repository(context);
Post post = repository.First<Post>(x => x.Id == 1);
Model model = new Model {
Created = cube.Created,
Id = cube.Id,
Name = cube.Name,
Pack = cube.Pack.Id,
Mimes = context.Files.Where(x => x.Id == 1).Select(x => x.Mime).ToList()
};
Run Code Online (Sandbox Code Playgroud)
我需要找到哪些SQL查询被发送到数据库.
如何使用SQL Express和VS 2012配置EF查询?
这有什么工具吗?