I have a dot net core 2 project that I develop on a Windows box, push to my linux box, then remote debug via vsdbg. Everything is working, except that the vscode window for selecting the process (via ${command:pickRemoteProcess}) pops up before the preLaunchTask starts.
My prelaunch task stops the program on my linux remote box, compiles my project, pushes it to the box, then restarts it on the linux box.
How can I delay the processId ${command:pickRemoteProcess} task until the preLaunchTask is completed?
Example task:
{
"label": "remotePush",
"command": "cmd",
"type": "shell",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "dedicated",
"showReuseMessage": true
},
"args": [
"/C ${workspaceFolder}/remotePublish.bat"
],
"problemMatcher": [
"$msCompile"
]
}
Example launch:
{
"name": "Remote Testing",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickRemoteProcess}",
"preLaunchTask": "remotePush",
"pipeTransport": {
"pipeProgram": "C:\\plink.exe",
"pipeArgs": ["-T", "administrator#myHost"],
"debuggerPath": "~/vsdbg/vsdbg",
},
"justMyCode": false,
"sourceFileMap": {
"/home/administrator/sites/mySite": "${workspaceRoot}"
}
}
Related
I am attempting to get VS Code to launch an asp.net mvc core website utilizing a specific port number. I would like to set this via the VS Code launch.json, and NOT utilize the appsettings.json files. I have referenced multiple websites that list a number of options, but none work other than using the appsettings.json file. Setting "ASPNETCORE_URLS":"https://localhost:5050" does not work, nor do setting the arguments.
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/WAPI.Foundation/bin/Debug/netcoreapp3.1/WAPI.Foundation.dll",
"args": [ ],
"cwd": "${workspaceFolder}/WAPI.Foundation",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
"uriFormat": "index.html"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS":"https://localhost:5050"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
] }
I have referenced among others: VSCode launch ASP.NET Core app on a specific port
The trick was to set the launch.json configuration command line "args" "--urls" property like so. I did not modify the "env" variables as described in other posts.
"configurations": [
{
"name": ".NET Core Launch (web)",
...
"args": ["--urls","https://localhost:44304;http://localhost:6000"],
"env": {
"ASPNETCORE_ENVIRONMENT": "Local"
},
...
}
]
I found the answer here: Launch specific URL in an ASP.NET Core app in VSCode when running the app.
Google searches on 'vs code setting port number' did not return this specific result, but search for 'vs code set url to run on' brought it right up.
I am trying to improve the build speed of one of my projects on CodeBuild. The project uses a Github source provider and source caching of type local is enabled.
The first time I ran the build it took 103 secs. I ran it again immediately after the first one finished expecting it to run in a few seconds due to source caching, but it took 60 secs.
What I am missing here? Is the cache not working? If it is working, why does it take that long on the second run?
Thanks
Project Details:
{
"projectsNotFound": [],
"projects": [
{
"environment": {
"computeType": "BUILD_GENERAL1_LARGE",
"imagePullCredentialsType": "SERVICE_ROLE",
"privilegedMode": true,
"image": "111669150171.dkr.ecr.us-east-1.amazonaws.com/***********/ep-build-env:latest",
"environmentVariables": [
{
"type": "PLAINTEXT",
"name": "NEXUS_URI",
"value": "http://***************"
},
{
"type": "PLAINTEXT",
"name": "REGISTRY",
"value": "111669150171.dkr.ecr.us-east-1.amazonaws.com/*********"
}
],
"type": "LINUX_CONTAINER"
},
"timeoutInMinutes": 60,
"name": "StorefrontApi",
"serviceRole": "arn:aws:iam::111669150171:role/CodeBuild-ECRReadOnly",
"tags": [],
"artifacts": {
"type": "NO_ARTIFACTS"
},
"lastModified": 1571227097.581,
"cache": {
"type": "LOCAL",
"modes": [
"LOCAL_DOCKER_LAYER_CACHE",
"LOCAL_SOURCE_CACHE",
"LOCAL_CUSTOM_CACHE"
]
},
"vpcConfig": {
"subnets": [
"subnet-fd7f958b"
],
"vpcId": "vpc-71e3f414",
"securityGroupIds": [
"sg-19b65e6c",
"sg-9e28e9f9"
]
},
"created": 1571082681.262,
"sourceVersion": "refs/heads/ep-mysql",
"source": {
"buildspec": "version: 0.2\n\nphases:\n build:\n commands:\n - env\n - cd extensions\n - mvn --settings $CODEBUILD_SRC_DIR_DEVOPS_WINE/pipelines/storefront/build-war/settings.xml --projects storefront/ext-storefront-webapp -am -DskipAllTests clean install\n\nartifacts:\n secondary-artifacts:\n storefront-war:\n base-directory: $CODEBUILD_SRC_DIR/extensions/storefront/ext-storefront-webapp/target\n files:\n - \"*.war\"\n\ncache:\n paths:\n - '/root/.m2/**/*'\n - '/root/.npm/**/*'",
"insecureSsl": false,
"gitSubmodulesConfig": {
"fetchSubmodules": false
},
"location": "https://github.com/*****************.git",
"gitCloneDepth": 1,
"type": "GITHUB",
"reportBuildStatus": false
},
"badge": {
"badgeEnabled": false
},
"queuedTimeoutInMinutes": 480,
"secondaryArtifacts": [],
"logsConfig": {
"s3Logs": {
"status": "DISABLED",
"encryptionDisabled": false
},
"cloudWatchLogs": {
"status": "ENABLED"
}
},
"secondarySources": [
{
"insecureSsl": false,
"gitSubmodulesConfig": {
"fetchSubmodules": false
},
"location": "https://github.com/*****************.git",
"sourceIdentifier": "DEVOPS_WINE",
"gitCloneDepth": 1,
"type": "GITHUB",
"reportBuildStatus": false
}
],
"encryptionKey": "arn:aws:kms:us-east-1:111669150171:alias/aws/s3",
"arn": "arn:aws:codebuild:us-east-1:111669150171:project/StorefrontApi",
"secondarySourceVersions": [
{
"sourceVersion": "refs/heads/staging",
"sourceIdentifier": "DEVOPS_WINE"
}
]
}
]
}
Apparently, at time of writing, CodeBuild does not use the native git client to fetch the source from GitHub. I understand that the CodeBuild internal teams have an internal feature request to move from whatever they're using to the native git client to improve performance.
Does your repository, by change, have lots of large files in its history? You can use this answer for a command to run to analyze your repository.
If you have lots of large files in your history and you're able to remove them, you can then use a tool like BFG Repo Cleaner to rewrite history. That should speed up the DOWNLOAD_SOURCE phase.
Also, if you have a dedicated support plan with AWS, you should reach out to your TAM to upvote the feature request to move to native git for GitHub source downloads.
I have two projects with common root opened in visual code. First is .net core webapi. Second is frontend on react/redux etc. Now when I want to run application I need to manually from console run 'npm start' and then run webapi from visual code. How can I achieve this with configuration of vs code?
At then end I want that after clicking debug I will have recompiled and deployed webapi and rebuild and same with frontend app. Then open browser in desired page.
There is an idea that I can run some script that would handle that, but I would prefer do it with pure vs code configuration.
I think that I need to modify my launch.json file. Don't know how though.
This is launch.json https://pastebin.com/9a66n3Rx
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/server/bin/Debug/netcoreapp2.0/webapi.dll",
"args": [],
"cwd": "${workspaceFolder}/server",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
Frontend app is in "${workspaceFolder}/client" folder
I have a docker container running Swagger UI on port 80 and I have another API running in another container on port 32788
http://127.0.0.1:80/ >>> returns swagger UI
http://127.0.0.1:32788/swagger.json >>> returns swagger API def
But when I put the json file into the Swagger UI field and hit explore, it says
NetworkError when attempting to fetch resource. http://127.0.0.1:32788/swagger.json
Any ideas on how to solve this. The docs say that they should automatically be connected to the bridge network.
Below is the result of the network inspection
docker network inspect bridge
[
{
"Name": "bridge",
"Id": "4b5cc1526055297df70dc9adc4959fcee93384c412fbf90500c041b5b83ed43a",
"Created": "2018-01-17T03:48:39.2325461Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"257a15af9ab9b25c6c5622fb0ebe599e5703b2ca5f2e4eaa97a8745a21e7f9a9": {
"Name": "pensive_neumann",
"EndpointID": "22be4b781f75e071bcb0098b917b81b16ca493e9080848188dd7a811c27070ec",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
},
"30de904a599a19075d5e20ef5d974a11be9d7e58a68d984a24f4af9e22c4d92b": {
"Name": "naughty_mirzakhani",
"EndpointID": "f704b3e103a82ca5c56d5955ac27845d8951cfe13f0bc3e1ccc8717ea9c28d39",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
Edit to explain how started each:
The API is part of Azure Machine Learning so its hard to say how it gets started exactly (unless there is some command I can run in docker):
az ml service create realtime
Swagger UI was started as follows:
docker run -p 80:8080 swaggerapi/swagger-ui
I'm trying to setup debugging on OSX environment using .NET Core RC2 and Visual Studio Code. The following error is given when trying to run the debugger.
Couldn't find 'project.json' in current directory
Currently I've setup launch.json (see below) and chosen .NET Core Launch (web) in Visual Studio Code.
As my project is in a folder called Core and sharing space with two other folders my structure looks like this.
Structure
--.vscode
------ launch.json
------ tasks.json
-- Core
-- Core.Data
-- Core.Service
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/Core/bin/Debug/netcoreapp1.0/Core.dll",
"args": [],
"cwd": "${workspaceRoot}/Core",
"stopAtEntry": false
},
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/Core/bin/Debug/netcoreapp1.0/Core.dll",
"args": [],
"cwd": "${workspaceRoot}/Core",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open",
"args": "-a chrome ${auto-detect-url}"
},
"linux": {
"command": "xdg-open"
}
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processName": "<example>"
}
]
}
Folder structure
I needed to add this code
tasks.json
"options":{
"cwd": "${workspaceRoot}/Core"
}
None of the answers helped me. I just specified the whole path to project.json and it began to work fine.
tasks.json
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}\\project.json"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]}
So, for this particular question it would be
"args": [
"${workspaceRoot}\\Core\\project.json"
],
I ran into this problem as well. I was able to fix it by specifying the content root for the WebHostBuilder in the entry point for the application. Make sure your entry point method looks something like this:
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
The important part of that code is:
.UseContentRoot(Directory.GetCurrentDirectory())
This tells the host where to find your site assets, including project.json and your MVC views.
On Ubuntu 16.10, I went into the tasks.json file and changed the \\ to / in the single args property like below:
"${workspaceRoot}\\project.json"
to
"${workspaceRoot}/project.json"
After that it worked flawlessly. Below is my entire tasks.json (it is from a dotnet core starter project)
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}/project.json"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
}