You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>If the tsconfig.json file under src folder does not contain skipLibCheck configuration, you need to add it, because current version of lodash typings has an error.</p>
26
+
<prelang="js">
27
+
"target": "es5",
28
+
<strong>"skipLibCheck": true,</strong>
29
+
"typeRoots": [
30
+
"../node_modules/@types"
31
+
]
32
+
</pre>
33
+
34
+
<p>If the tsconfig.json file under e2e folder contains below configuration</p>
35
+
<prelang="js">
36
+
"extends": "../tsconfig.json"
37
+
</pre>
38
+
You need to change it like this, becasue above configuration is wrong.
<p>Since we copied .gitignore file from another project, we need to remove lines under "<strong># VS files</strong>" which contains "<strong>PhoneBook.AngularUI</strong>" keyword.</p>
We need to exclude "<strong>node_modules</strong>" and "<strong>external_libs</strong>" folders from compiled folders. In order to do that, change your buildOptions in project.json like this:
32
-
<prelang="js">
33
-
"buildOptions": {
34
-
"emitEntryPoint": true,
35
-
"preserveCompilationContext": true,
36
-
"copyToOutput": "log4net.config",
37
-
<strong>"compile": {
38
-
"exclude": [
39
-
"node_modules",
40
-
"external_libs"
41
-
]
42
-
}
43
-
</strong> }
50
+
We need to exclude "<strong>node_modules</strong>", "<strong>dist</strong>" and "<strong>external_libs</strong>" folders from compiled folders. In order to do that, add below content to your csproj file's content:
After doing this, your project must be build successfully.
46
73
</p>
47
74
48
-
<h4id="DocStep4">Step 4: Running the host project</h4>
75
+
<h4id="DocStep5">Step 5: Running the host project</h4>
49
76
<p>
50
77
Now, we can run our host project by pressing the F5 button. We assume that, you have already applied migrations to your database and runned host project before starting this document according to <ahref="Getting-Started-Angular.html">ASP.NET Core & Angular 2+</a> document.
51
78
</p>
52
79
53
-
<h4id="DocStep5">Step 5: Running the client (Angular 2.x) project</h4>
80
+
<h4id="DocStep6">Step 6: Running the client (Angular 2.x) project</h4>
54
81
<p>
55
82
We need to open a command prompt and navigate to "<strong>..\src\Acme.PhoneBook.Web.Host</strong>" folder. Then we need to run "<strong>npm install</strong>" command in order to install our project's dependencies.
56
83
Then we can run "<strong>npm start</strong>" command to start our project.
Our client project is published by angular-cli. In order to publish a single website using Visual Studio, first we need to modify publish directory for angular-cli. In order to do that, open <strong>angular-cli.json</strong> in your project and change value of <strong>"outDir"</strong> to <strong>"wwwroot/dist"</strong>.
96
+
Our client project is published by angular-cli. In order to publish a single website using Visual Studio, first we need to modify publish directory for angular-cli. In order to do that, open <strong>.angular-cli.json</strong> in your project and change value of <strong>"outDir"</strong> to <strong>"wwwroot/dist"</strong>.
70
97
We could use "wwwroot" as outDir but, angular-cli deletes entire folder before it builds the application. So, In order not to loose other files under
71
-
<strong>wwwroot </strong>folder, we ued<strong>wwwroot/dist</strong>.
98
+
<strong>wwwroot </strong>folder, we used<strong>wwwroot/dist</strong>.
72
99
</p>
73
100
74
101
<h4id="PubStep2">Step 2: Build client app before publish</h4>
75
102
<p>
76
-
Before publishing our application using Visual Studio's publish, we need to build our angular application using angular-cli. We can do it using <strong>prepublish</strong> scripts. Add <strong>"ng build --prod"</strong> to your prepublish script in project.json. Your scripts in project.json will be like this:
Before publishing our application using Visual Studio's publish, we need to build our angular application using angular-cli. Your *.Web.Host.csproj will be like this:
In this way, angular-cli is going to build your client application before every publish you make.
86
109
</p>
87
110
88
111
<h4id="PubStep3">Step 3: Move client app files to wwwroot</h4>
89
112
<p>
90
-
We need to move files and folders under "<strong>wwwroot/dist</strong>" to "<strong>wwwroot</strong>". In order to do that, change your <strong>prepublish</strong> scripts like this:
We need to move files and folders under "<strong>wwwroot/dist</strong>" to "<strong>wwwroot</strong>". In order to do that, change your *.Web.Host.csproj like this:
This command copies entire content of <strong>wwwroot\dist</strong> folder to <strong>wwwroot </strong> and deletes dist folder before publish. In this way, will have a clean wwwroot folder.
<p>We also need to remove HomeController from our project, so the app's default route will be our angular client app. We can still access to swagger ui under
144
+
<strong>/swagger/ui/index.html</strong>.</p>
122
145
123
146
<p>Now, we can publish our website using Visaul Studio's publish at once.</p>
124
147
<h3>After Publish</h3>
125
148
<p>
126
149
Our client and server applications are designed to work separately. Because of that, they have different configurations. In order to make them work together, we need to make some configurations after publish as well.
127
150
We need to use same address configured for our host application in <strong>appsettings.json</strong> for our angular2 application.
128
-
Copy the value of "<strong>WebSiteRootAddress</strong>" in appsettings.json and use this value for "<strong>remoteServiceBaseUrl</strong>" and "<strong>appBaseUrl</strong>" in "<strong>appconfig.json</strong>" under "<strong>wwwroot\assets\</strong>" folder.
151
+
First configure your appsettings.json file for values "<strong>ServerRootAddress</strong>", "<strong>ClientRootAddress</strong>", "CorsOrigins". ServerRootAddress and ClientRootAddress must be same since we are hosting client and server together. If you are using subdomain per tenancy, then you need to include allowed addresses into CorsOrigins, otherwise CorsOrigins will be same as ServerRootAddress and ClientRootAddress.
152
+
Then, copy the value of "<strong>ServerRootAddress</strong>" in appsettings.json and use this value for "<strong>remoteServiceBaseUrl</strong>" and "<strong>appBaseUrl</strong>" in "<strong>appconfig.json</strong>" under "<strong>wwwroot\assets\</strong>" folder.
129
153
</p>
130
154
<p>
131
-
Now you can view your website under "<strong>http://yourwebsite.com/index.html</strong>". If you enter only http://yourwebsite.com/, it will redirect you to swagger ui (to swagger/ui/index.html), so you need to add index.html after your website name.
155
+
Now you can view your website under "<strong>http://yourwebsite.com/</strong>". If you want to view swagger ui, then you can use http://yourwebsite.com/swagger/ui/index.html.
132
156
</p>
133
157
<divclass="alert alert-warning">
134
158
Notice that, appsettings.json and appconfig.json are two different files.
0 commit comments