【发布时间】:2020-02-19 15:18:16
【问题描述】:
我使用 Visual Studio 2019(社区版)应用了 Angular 8 和 .Net Core 2.2(Web API)。为了将两个项目保持在单一解决方案中,我遵循了此链接中给出的说明: Add angular 7.0 client application to asp.net core 2.2 web api project
它在一段时间内工作得很好,现在给出如下图所示的构建错误。而我可以在命令提示符下使用 ng serve 命令运行应用程序,但无法使用 Visual Studio 2019 构建。
我尝试通过更改 tsconfig.json 中的设置来解决错误,但到目前为止还没有成功。找到我当前的 tsconfig.json 如下:
{
"compileOnSave": true,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"module": "esnext",
"moduleResolution": "node",
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": false,
"strictInjectionParameters": true
}
}
请帮助解决上述情况。我不知道如何共享代码,但我可以将代码作为学习应用程序共享。
其次,有没有其他方法可以将 Angular 和 .Net Core Web Api 保留在单个项目中?
【问题讨论】:
-
构建失败,因为您在 html 或 ts 文件中有错误。我认为您在 html 文件中使用了变量,但变量未在 ts 文件中定义。
-
@upinderkumar 不,事实并非如此。我可以使用 ngserve 命令运行应用程序而不会出现任何错误。
标签: angular visual-studio .net-core asp.net-core-webapi visual-studio-2019