两个不同的Web应用程序。两者都以带有角模板的asp.net核心开始。在第二种情况下,Im生成了angular6应用。 angular6应用在本地运行良好。这是从Visual Studio的发布步骤开始的,在第二种情况下情况会有所不同。
(1)一个使用asp.net core w / angular 5模板的测试用例。可以正常工作,可以发布到本地IIS网站,也可以在那里正常工作。发布到IIS时,我得到了“ ClientApp”文件夹
package.json脚本部分
"name": "aspnetcore_dummy1",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --extract-css",
"build": "ng build --extract-css",
"build:ssr": "npm run build -- --app=ssr --output-hashing=media",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
来自tsconfig.json
"compilerOptions": {
"outDir": "./dist/out-tsc",
(2)
带角6的asp.net核心应用
project.json脚本部分
"name": "client-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
来自tsconfig.json
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
在两种情况下,这都是Configureups的Startup.cs外观
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});
}
但是,当发布到IIS时,情况(1)使用ClientApp / dist文件夹是正确的,但是(2)我没有在ClientApp下获得'dist'文件夹,而是获得了'e2e','src'文件夹和一些设置文件。查看图片
[更新]-有效的csproj文件中的内容,而另一个csproj文件中没有的内容
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --prod" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr -- --prod" Condition=" '$(BuildServerSideRenderer)' == 'true' " />
<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" />
<DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" />
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
答案 0 :(得分:2)
在上面来自itmius的建议注释中,我调查了项目文件的详细信息。实际上,这是发布期间执行许多操作的地方。与其试图跟踪这个和/或其他“遗留的”配置部分,我只是从空白开始-一个新的带有角项目模板的asp.net核心,然后复制到现有的clientapp文件夹中,然后我回来了业务。