VS Code can't download symbols for test app - visual-studio-code

I would like to create a test environment for my app running in BC18, but I have trouble downloading the necessary symbols. I created a new workspace along with a .vscode/launch.json and an app.json-file, which contains the following properties:
"dependencies": [
{
"id": "65d313b7-f655-41af-9325-3ade0d3489e9",
"name": "Main App",
"publisher": "My Company",
"version": "1.0.1.0"
}
],
"test": "17.0.0.0"
However, when trying to download the symbols, I always get the following error:
[2021-05-18 15:39:06.44] The request for path /BC/dev/packages?publisher=Microsoft&appName=Test&versionText=17.0.0.0&tenant=default failed with code NotFound. Reason: No published package matches the provided arguments.
[2021-05-18 15:39:06.44] The following dependencies will be queried for propagated dependencies:
Application by Microsoft (18.0.0.0)
[2021-05-18 15:39:06.44] Sending request to http://ll-bc-at:7049/BC/dev/packages?publisher=Microsoft&appName=Application&versionText=18.0.0.0&tenant=default
[2021-05-18 15:39:06.45] Could not download reference symbols. Please ensure that:
1. The correct server name and instance are specified in the launch.json file.
2. The correct application version is specified in the app.json file.
3. The dependencies are correctly specified in the app.json file.
I've tried reinstalling the container, making sure the test toolkit is included and confirmed it is working properly by accessing the default test suite in the Test Tool, but nothing so far has been successful. Using different version for test hasn't had an effect either.

The test property has been deprecated. You will need to add the dependecies for the various test extensions you want to use.
I normally use these dependencies as a starting point:
{
"id": "e7320ebb-08b3-4406-b1ec-b4927d3e280b",
"name": "Any",
"publisher": "Microsoft",
"version": "17.0.0.0"
},
{
"id": "23de40a6-dfe8-4f80-80db-d70f83ce8caf",
"name": "Test Runner",
"publisher": "Microsoft",
"version": "17.0.0.0"
},
{
"id": "dd0be2ea-f733-4d65-bb34-a28f4624fb14",
"name": "Library Assert",
"publisher": "Microsoft",
"version": "17.0.0.0"
},
{
"id": "9856ae4f-d1a7-46ef-89bb-6ef056398228",
"name": "System Application Test Library",
"publisher": "Microsoft",
"version": "17.0.0.0"
},
{
"id": "5d86850b-0d76-4eca-bd7b-951ad998e997",
"name": "Tests-TestLibraries",
"publisher": "Microsoft",
"version": "17.0.0.0"
}

Related

VSCode - How to specify which project to debug - Azure Functions

My question is a noobie question.
I have an azure function app project, along with a test project. Initially, I start with just the function application project and then I just recently re-org the project folders and added the associated test.csproj
The folder structure I have right now looks like this:
Since moving the function app into the "src" folder, when I want to just run locally, I make sure that from my powershell terminal, I do the following:
cd src
func start
And everything works really well. But if I want to step through the code / debug, hitting F5 doesn't work because it doesn't know which project I'm trying to debug.
Can you tell me how I can debug either project from the parent folder that I'm in ?
I've tried to change my launch.json from this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
}
To this:
{
"version": "0.2.0",
"configurations": [
{
"name": "FunctionApp",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}",
"program": "${workspaceFolder}/src/bin/Debug/net6.0/bin/widgets.dll",
"cwd": "${workspaceFolder}/src"
}
]
}
And now I see a Green play button with the name "FunctionApp" in my "Run and Debug" bar across the top, but when I try to run it, I get an error that says:
Executing task: C:\Program Files\dotnet\dotnet.exe clean /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary <
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Copyright
(C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1003: Specify a project or solution file. The
current working directory does not contain a project or solution file.
The terminal process "C:\Program Files\dotnet\dotnet.exe 'clean',
'/property:GenerateFullPaths=true',
'/consoleloggerparameters:NoSummary'" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
EDIT 1
I tried to follow this example:
https://i.stack.imgur.com/a7ZVk.png
I also changed all references in my task.json from "process" to "shell" based on this post: Debugging Azure Function with vscode
So presently, this is what the two files look like:
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
}
tasks.json
Just showing what I understand is the relevant section...
{
"version": "2.0.0",
"tasks": [
{
"label": "host function",
"command": "func host start",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/src"
}
},
But the error I'm getting is this:
Failed to detect running Functions host within "60" seconds. You may
want to adjust the "azureFunctions.pickProcessTimeout" setting.
When I try Run -> Start with debugging, the application starts, and I can trigger my API... but it doesn't stop at any of the breakpoints.
So the complete solution was to
a) Revert my launch.json back to the original version which looks like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
}
b) added new section to my tasks.json:
{
"label": "host function",
"command": "func host start",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/src"
}
},
c) Then I changed ALL references to "process" to "shell" in the tasks.json.
d) Lastly, to fix the error with azureFunctions.pickProcessTimeout, I did the following:
File -> Preferences -> Settings -> search for the specific setting and increased from 60 seconds to 180

From within a Build/Release pipeline, can we discover its path?

In Azure DevOps, we can organize our Build/Release definitions into high-level folders:
Example: for every pipeline that resides in the Framework folder, I want to conditionally execute a certain task. The pre-defined Build and Release variables provide a plethora of ways to discover information about the underlying file system, but seemingly nothing for this internal path information.
During a pipeline run, is it possible to determine the folder/path that it resides in?
You can check it with Rest API - Builds - Get:
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=6.0
In the response you get the definition details including the path:
"definition": {
"drafts": [
],
"id": 13,
"name": "TestBuild",
"url": "https://dev.azure.com/xxxxx/7fcdafd5-b891-4fe5-b2fe-xxxxxxx/_apis/build/Definitions/13?revision=1075",
"uri": "vstfs:///Build/Definition/13",
"path": "\\Test Folder",
"type": "build",
"queueStatus": "enabled",
"revision": 1075,
"project": {
"id": "7fcdafd5-b891-4fe5-b2fe-9b9axxxxx",
"name": "Sample",
"url": "https://dev.azure.com/xxxx/_apis/projects/7fcdafd5-b891-4fe5-b2fe-9xxxxxx",
"state": "wellFormed",
"revision": 97,
"visibility": "private",
"lastUpdateTime": "2021-03-22T10:25:39.33Z"
}
},
So:
Add a simple PS script that invokes the rest API (with the $(Build. BuildId) pre-defined variable)
Check the value of the path property
If it contains the Framework folder set a new variable with this command:
Write-Host "##vso[task.setvariable variable=isFramework;]true"
Now, in the task add a custom condition:
and(succeeded(), eq(variables['isFramework'], 'true'))

How do you add a checkbox input to an Azure DevOps Task Group?

In Azure DevOps, I have created a Task Group that runs Postman tests using the newman CLI. As inputs, users can pass in the paths to the Postman collection and environment files.
As the newman CLI is a requirement, the first task in the Task Group is to install it. However, in scenarios where several collections are run, there is no need to keep installing the CLI over and over, so I would like to offer a checkbox and then conditionally run the install task depending on the value of that checkbox.
As the UI for Task Groups is pretty lacking in useful options, I started exploring the API. I'm able to add additional inputs, but setting the obvious type option to checkbox yields only an additional text (string) input.
POST https://dev.azure.com/{org}/{project}/_apis/distributedtask/taskgroups?api-version=5.1-preview.1
{
...
"inputs": [
{
"aliases": [],
"options": {},
"properties": {},
"name": "Rbt.Cli.Install",
"label": "Install 'newman' CLI?",
"defaultValue": true,
"required": false,
"type": "checkbox",
"helpMarkDown": "Choose whether or not to install the 'newman' CLI. You only need to install it if it hasn't already been installed by a previos task running on this job.",
"groupName": ""
},
...
],
...
}
Looking more closely at the documentation, there is a definition for inputs - TaskInputDefinition. However, it looks as though whoever was tasked with writing that documentation left early one day and never got around to it. There are no descriptions at all, making it impossible to know valid values for properties in the definition.
How can I add a checkbox to my Task Group?
I have now found that Task Groups offer picklist as an input type. This has allowed be to present a yes/no option to the user, and based on their answer I am able to conditionally run a task.
I would still prefer to have a checkbox though, should anyone know how to do that.
{
"aliases": [],
"options": {
"yes": "Yes - install CLI",
"no": "No - the CLI has already been installed"
},
"properties": {},
"name": "Postman.Cli.Install",
"label": "Install 'newman' CLI?",
"defaultValue": "yes",
"required": true,
"type": "picklist",
"helpMarkDown": "Choose whether or not to install the 'newman' CLI. You only need to install it if it hasn't already been installed by a previos task running on this job.",
"groupName": ""
}
You can add checkbox to pipeline task easily by setting the type as boolean
{
"name": "Rbt.Cli.Install",
"type": "boolean",
"label": "Install 'newman' CLI?"
}
And also control the visibility of other controls based on the check box state as following:
{
"name": "someOtherField",
"type": "string",
"label": "Some other field",
"visibleRule": "Rbt.Cli.Install = true"
},

Where to define a shared problemMatcher to check the terminal?

In vscode I experience sometimes I can click on build errors in the integrated terminal and sometimes it is not possible to do so. This has annoyed me for quite some time because I was not able to find a pattern, until today when I was editing tasks.json.
It looks to be related to defining a problemMatcher in .vscode/tasks.json. Removing the problemMatcher section from the file and build errors in terminal were no longer clickable but putting it back did not re-enable them.
My vscode-project is located in a subfolder of the build tree and its build root for the entire project is two levels up ${workspaceFolder}/../.. which I believe maybe could confuse some build tools.
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"problemMatcher": {
"fileLocation": "relative",
"severity": "error",
"pattern":{
"regexp": "^system/mytool/(.*):(\\d+):(\\d+):\\s+(warning|error):(.*)$",
"file": 1,
"location": 2,
"column": 3,
"severity": 4,
"message": 5
},
},
"tasks": [
{
"type": "shell",
"label": "android deploy",
"command": "cd ${workspaceFolder}/../..; source build/envsetup.sh ; lunch hikey960-userdebug ; m mytool",
"args": [
],
"options": {
},
"group": "build"
},
]
}
I have seen examples putting "problemMatcher" = "$gcc" inside the task, should I define my problem matcher globally somewhere else and refer to it my name instead?
How to use it to parse the output when I build by typing make-commands in the integrated terminal?
You cannot define problem matchers globally. Instead you have to define them in each task.
This is somewhat ugly because you may have to copy the same problem matcher into a lot of tasks. There is an open issue for this: Global task properties

Automating build task with unique ids

I've written some embedded code (using VS-Code as my IDE) that is ready for deployment to many different devices.
The code contains a file config.h that defines a unique device_id that needs to change for each device.
I have a file unique_ids.csv that contains all of the unique ids that I need to use.
VS-Code can automatically build my project and creates a file called project_name.bin.
How can I set up a script that automatically takes the uniqe ids from my CSV file and builds a specific device_id.bin file for each one?
I suspect this may require utilizing Visual Studio Tasks in some way. Here is my current tasks.json:
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"name": "make",
"isShellCommand": true,
"showOutput": "always",
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/mbed-os"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
"args": ["-j"],
"linux": {
"command": "make"
},
"osx": {
"command": "make"
},
"windows": {
"command": "make.exe"
}
}
Thinking of an alternative approach, I might not be answering directly.
If you are using the csv for release and not for debug, why would you build the release inside VS?
I would rather build my debug inside VS and build my different releases using command line with a batch script.
Something like this batch pseudo code
set id_list=unique_ids.csv
set id=
for %%a in (%id_list%) do (
set "id=%%~na"
replace in config.h device_id by device_%id%
make your_project
)