Set up Visual Studio 2017 for .Net Core Application Development
The Default Profile setting in LibPrograms/Properties/LaunchSettings.json
{
"iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": true,
"iis": {
"applicationUrl": "http://localhost:8000",
"sslPort": 0
},
"iisExpress": {
"applicationUrl": "http://localhost:49497/",
"sslPort": 0
}
},
"profiles": {
"IIS": {
"commandName": "IIS",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IISExpress": {
"commandName": "IIS",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"use64Bit": false
},
"LibPrograms": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:49498/"
}
}
}
- Enable Development time IIS support for .Net Core Application
This setup is for running with IIS profile. Without this setup, you'll see error "AspNetCore module is not installed ..." when you try to click IIS profile to run.Firstly download and run Visual Studio Installer:
Then check Development time IIS support from ASP.NET and web development.
For details please refer to .NET Web Development and Tools Blog.
- Self-contained deployment with Visual Studio
Edit LibPrograms.csproj file and add the following highlight lines and the publish the project:<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<NoWarn>$(NoWarn);NU1605</NoWarn>
</PropertyGroup>
...
</Project>
Please note: <NoWarn>$(NoWarn);NU1605</NoWarn> is for working around the following publishing error: .NET Core 2.0.0 - downgrade warnings have become errors when running package restore #5594.
LibPrograms -> Microsoft.VisualStudio.Web.CodeGeneration.Tools 2.0.0 -> Microsoft.Build.Runtime 15.3.409 -> Microsoft.Build 15.3.409 -> System.IO.Pipes 4.0.0 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Security.Principal.Windows 4.3.0 -> System.Security.Principal (>= 4.3.0)
LibPrograms -> Microsoft.VisualStudio.Web.CodeGeneration.Tools 2.0.0 -> Microsoft.Build.Runtime 15.3.409 -> Microsoft.Build 15.3.409 -> System.IO.Pipes 4.0.0 -> System.Security.Principal (>= 4.0.1) LibPrograms
For details of deployment please refer to Deploying .NET Core apps with Visual Studio,
Self-contained app can be run in the following ways:
- C:\>LibPrograms.csproj.exe
- C:\>C:\Program Files\dotnet\dotnet.exe LibPrograms.csproj.dll
- Deployed to IIS, for example deployed to http://localhost:8000 at C:\inetpub\wwwroot\LibPrograms
When you trying to access http://localhost:8000, you most likely see the following error:
HTTP Error 502.5 - Process Failure
Please edit C:\inetpub\wwwroot\LibPrograms\web.config and remove the -argFile IISExeLauncherArgs.txt. Now it should work.
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\LibPrograms.exe" arguments="-argFile IISExeLauncherArgs.txt" forwardWindowsAuthToken="true" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
Credit to danielyewright at ASP.Net Core app - HTTP Error 502.5 - Process Failure
- Framework-dependent deployment with Visual Studio
The working LibPrograms.csproj file is as follows:<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
...
</Project>
During deployment I kept receiving this error:
Severity Code Description Project File Line Suppression State
Error Assets file 'C:\dev\wan\LibPrograms\LibPrograms\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0/win10-x64'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. You may also need to include 'win10-x64' in your project's RuntimeIdentifiers. LibPrograms
Referring to VS2017 publish: project.assets.json doesn't have a target for .NETCoreApp,Version=v1.1 #1321, Juslwk's solution worked for me which is:
In Publish / Settings / Databases / Check Use this connection string at runtime
What was weird is: after this success, the deployment always worked even though I unchecked Use this connection string at runtime. Caused by cache? Any update to publish settings may fix it. For example, delete and create the profile for publish.
If HTTP Error 502.5 - Process Failure error showed up again, please edit web.config and remove -argFile IISExeLauncherArgs.txt as follows:
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\LibPrograms.dll -argFile IISExeLauncherArgs.txt" forwardWindowsAuthToken="true" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
Please don't forget Install the .NET Core Windows Server Hosting bundle.
Please don't forget Install the .NET Core Windows Server Hosting bundle.
- The best way to remove "argFile IISExeLauncherArgs.txt"
Method 1: in Visual Studio , directly remove the high light content from the source web.config
<aspNetCore processPath="bin\IISSupport\VSIISExeLauncher.exe" arguments="-argFile IISExeLauncherArgs.txt" forwardWindowsAuthToken="true" stdoutLogEnabled="false" >
</aspNetCore>
Method 1: in Visual Studio , directly remove the high light content from the source web.config
</aspNetCore>
Method 2: Using PowerShell Script
BlueWater86 commented 21 days ago •
The same can be achieved by using a powershell script. Put the file in the root of your project and set it to 'Content', 'Copy Always'.
CleanDeployArgs.ps1:
Line at the bottom of your csproj file:
|
This comment has been removed by a blog administrator.
ReplyDelete