I'm writing a .NET Core MVC Application targeting Framework 461 instead of .NET Core. Reason: I am using a library which is not yet ready for .net core but will be soon.
I am doing this in Visual Studio Code and have several questions:
- Debugging starts but breakpoints are not hit. Can't see why as the controller call is successful.
- Why does the build process produces an exe instead of a dll when switching the framework from core to net 461 in project.json
- Why is there an exe file beneath debug/net461/ & debug/net461/win7-x64.
I assume I'm doing something completely wrong with the build process in launch.json & task.json or with the project.json but I can't see the problem. I think all questions are related to my problem so I raise them in one thread.
UPDATE 1: Opened the project.json in full Visual Studio 2015, hit F5 and debugging works perfekt. So must be an issue with my visual studio code config. Works with IIS Express & Kestrel.
UPDATE 2: Set emitEntryPoint to false. Now it produces a dll, but can no longer run the the application now. different error...jfy
project.json
{
"dependencies": {
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"net461": {
"dependencies": {
"System.Management.Automation": "6.1.7601.17515"
}
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"tooling": {
"defaultNamespace": "BeyondAgent"
}
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}\\bin\\Debug\\net461\\win7-x64\\BeyondAgent.exe",
"args": [],
"cwd": "${workspaceRoot}",
"externalConsole": false,
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command.pickProcess}"
}
]
}
tasks.json
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}\\project.json"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
}
code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using BeyondAgent.Services;
using BeyondAgent.ViewModels;
namespace BeyondAgent.Controllers
{
[Route("api/[controller]")]
public class DscController : Controller
{
IViewModelService _viewModelService;
IDscPowerShellService _dscPowerShellService;
public DscController(IDscPowerShellService dscPowerShellService, IViewModelService viewModelService)
{
//BREAKPOINT HERE NOT HIT! _dscPowerShellService = dscPowerShellService;
_viewModelService = viewModelService;
}
}
}