简体   繁体   English

如何将ASP.NET MVC 5 Angular 4应用程序部署到IIS服务器中?

[英]How to deploy ASP.NET MVC 5 Angular 4 app into IIS server?

I am very new to Angular and started learning Angular. 我是Angular的新手,并开始学习Angular。 Currently,I am using Visual Studio 2017 to build the Angular app. 目前,我正在使用Visual Studio 2017来构建Angular应用程序。 Basically, my aim is to combine both technologies together where I can use the ASP.NET MVC engine in the back-end and angular features in the front-end. 基本上,我的目标是将两种技术结合在一起,以便可以在后端使用ASP.NET MVC引擎,在前端使用角度功能。

I have copied the angular-quick tutorial setup from the github and incorporate with my MVC project.It is running locally without any problem. 我已经从github复制了angular-quick教程设置并合并到了我的MVC项目中,它在本地运行没有任何问题。

Now I want to publish this apps from Visual Studio 2017 into local IIS server. 现在,我想将此应用程序从Visual Studio 2017发布到本地IIS服务器中。 It appears that the IIS server does not know how to read the system.config.js files. 看来IIS服务器不知道如何读取system.config.js文件。 I am not able to run the apps from the server. 我无法从服务器运行应用程序。

Do I need to move all the node_modules files into IIS server? 我是否需要将所有node_modules文件移动到IIS服务器中?

Thanks in advance. 提前致谢。

When your all the development part is done, you can publish it under Internet Information Server (IIS). 完成所有开发部分后,可以将其发布到Internet Information Server(IIS)下。

Need to create a production bundle of the Angular 4 application and add hooks into the publishing pipeline that also publishes the production bundles of the Angular 4 application with the rest of the deployment to IIS. 需要创建Angular 4应用程序的生产包并将钩子添加到发布管道中,该发布管道还将Angular 4应用程序的生产包连同其余的部署发布到IIS。

To create production bundles of the Angular application,.csproj project file should be edited and added a production build command to the AfterBuild target. 要创建Angular应用程序的生产包,应编辑.csproj项目文件并将生产构建命令添加到AfterBuild目标。

<Target Name="AfterBuild">
<Exec Command="ng build --prod --deploy-url http://localhost/yourproject/dist/" WorkingDirectory="$(ProjectDir)" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />

<Exec Command="ng build --deploy-url http://localhost:55499/dist/" WorkingDirectory="$(ProjectDir)" Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
</Target>

Please add below command to the project file which will get executed when publishing the application. 请在项目文件中添加以下命令,该文件将在发布应用程序时执行。

<Exec Command="ng build --prod --deploy-url http://localhost/yourproject/dist/" WorkingDirectory="$(ProjectDir)" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM