[英]How to remove the virtually added angular files from the .net core web api project
I want to start a new project using asp.net core web.api and angular 9. As a start, I want to create a .net core web api project without MVC or scaffolded angular project. I want to start a new project using asp.net core web.api and angular 9. As a start, I want to create a .net core web api project without MVC or scaffolded angular project. What I also would like is to start the spa when the web.api is launched, the same way it works with a scaffolded create asp.net core web application (version 3.1) with Angular.
What I also would like is to start the spa when the web.api is launched, the same way it works with a scaffolded create asp.net core web application (version 3.1) with Angular. I want to use this scaffold as my source, but out of the box, there are some things I don't like about this scaffolded project.
我想使用这个脚手架作为我的源代码,但是开箱即用,我不喜欢这个脚手架项目的一些东西。 The version of the angular is 8, not 9 but a simple update could fix that I guess.
angular 的版本是 8,而不是 9,但我猜一个简单的更新可以解决这个问题。 The other thing I try to achieve is change the folder structure and replace the angular project out of the web api project.
我尝试实现的另一件事是更改文件夹结构并从 web api 项目中替换 angular 项目。
The original folder structure is:原来的文件夹结构是:
Solutionfolder
|- WebApi project
|- ClientApi (which contains the angular project)
What I want is:我想要的是:
Solutionfolder
|- WebApp (which contains the angular project)
|- WebApi project
As I believe the angular project doesn't belong in the web api project.我相信 angular 项目不属于 web api 项目。 To achieve this, I started a new asp.net core web application with .net core version 3.1 and choosing Angular in the proces and then I did the following steps:
To achieve this, I started a new asp.net core web application with .net core version 3.1 and choosing Angular in the proces and then I did the following steps:
configuration.RootPath = "../ClientAppChanged/dist";
spa.Options.SourcePath = "../ClientAppChanged";
<SpaRoot>..\ClientAppChanged\</SpaRoot>
<SpaRoot>..\ClientAppChanged\</SpaRoot>
And this works but the last step seems to cause a nasty side effect: it adds virtually the angular project files to the WebApi project:这可行,但最后一步似乎会引起讨厌的副作用:它实际上将 angular 项目文件添加到 WebApi 项目中:
So my final step is to get rid of the virtually added files but I cannot figure out why it is added.所以我的最后一步是摆脱虚拟添加的文件,但我不知道为什么要添加它。 My best guess is it got to do with the spaRoot setting in the.csproj file.
我最好的猜测是它与 .csproj 文件中的 spaRoot 设置有关。 My question is: why is the files virtually added to the web API project file and how can I stop this?
我的问题是:为什么这些文件实际上被添加到 web API 项目文件中,我该如何阻止这个?
After some more searching, I found a topic which helped me in the right direction.经过一番搜索,我找到了一个帮助我朝着正确方向发展的主题。 In the.csproj file, the next line is causing the added files virtually to the project:
在 .csproj 文件中,下一行将添加的文件虚拟地添加到项目中:
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
After removing this line of code, the files aren't shown anymore as part of the project:删除这行代码后,文件不再作为项目的一部分显示:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.