I'm experimenting with PowerShell and having a little trouble understanding parameters.
I added
Param([string]$EmployeZip)
in the .ps1 file.
Also tried
Param([Parameter(Mandatory=$false)] [System.String] $EmployeZip)
And I need to make it as an optional value so the user need not have to enter it.
I am trying to make a VSTS task using this powershell.The issue is, it is looking for the EmployeZip as a mandatory filed, instead of as an optional filed.
How can I make it as an optional filed?
Thanks for the quick responses.
I found it.
inputs": [
{
"name": "EmployeZip",
"type": "string",
"label": "EmployeZip",
"defaultValue": "",
"required": false,
"helpMarkDown": "I"
}
I have to make the "required": false, in the task.json file. it was true.
Related
when I try to change my vscode theme, I get a message saying "Unable to write into user settings" and to correct any errors. I checked my setting but didn't know what was wrong with it. Does anyone see any mistakes? I've pasted my settings code below.
"launch": {
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Local Node File",
"console": "integratedTerminal",
"program": "${file}"
},
{
"name": "Launch index.html",
"type": "chrome",
"request": "launch",
"file": "${workspaceFolder}/index.html"
},
{
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
"emmet.includeLanguages": { "erb": "html" }
},
"liveSassCompile.settings.formats": [
{
"format": "expanded",
"extensionName": ".css",
"savePath": "/css"
}
],
"liveSassCompile.settings.generateMap": false
]
}
IMO, the real problem is not how to fix the JSON, the real problem is the error msg "Unable to write into user settings". This tells me nothing useful; it makes the issue sound like a permissions problem, not a faulty comma or something in JSON.
I came here because I got the "Unable..." error in VSC, and had no idea how to fix it. The error msg unhelpfully suggests logging into the shared settings, which I unsuccessfully (apparently) attempted to do several times in different ways. That was not the problem at all. Once I fixed a stray comma in my JSON, as implied here, the error went away.
BTW, I'm not looking for upvotes, since this page already explains what the issue is. I'm venting my frustration with VSC...
open your settings.json, find the way line and annotation it
There's 2 problems going on.
1. How to identify JSON syntax errors
I get a message saying ... to correct any errors
...
Does anyone see any mistakes?
Any kind of json linter will tell you if your json is valid.
You could use VSCode itself, but since we're on the web, paste your json into https://jsonlint.com/ and right away it shows you there's an error:
Error: Parse error on line 1:
"launch": { "version": "0.2
--------^
Expecting 'EOF', '}', ',', ']', got ':'
It even has a little ascii art "arrow" pointing to the character that's the problem.
It's complaining because your json has a key ("launch") that's not inside an object ({...}). Compare your json to the launch configuration examples in VSCode Debugging docs, you'll notice that your "launch": is not in those examples. Just remove that so it starts from the first {, i.e.
When you fix that first problem, you hit your second problem:
2. "liveSassCompile.settings.formats" in wrong place
It's the same error as above: a json key not in an object.
Error: Parse error on line 23:
...le.settings.formats": [{ "format": "e
-----------------------^
Expecting 'EOF', '}', ',', ']', got ':'
In this case, it's because you pasted styling settings ("liveSassCompile.settings.formats": { ... }) into the launch configurations array.
You'll need to find the right place to paste those settings, but it's not inside that array — or anywhere in the launch config.
Check if running vs code as administrator solves your problem, the problem is from permissions that you have. ( only check for troubleshooting ).
Also, your JSON format must be valid for save.
I'm working on a VS Code Extension, and I think maybe I'm missing something in the docs, or else the behavior I'm seeing just isn't specified there, and my assumptions are wrong...?
I've defined some default settings for my extension, like so...
package.json
"contributes": {
"configuration": {
"title": "ToggleSettingsChanges",
"properties": {
"toggleSettingsChanges.settingsToToggle": {
"scope": "resource",
"type": "object",
"default": {
"window.zoomLevel": 2,
"editor.fontSize": 22,
"terminal.integrated.fontSize": 16,
"scm.diffDecorations": "none",
"workbench.statusBar.visible": false,
"editor.cursorBlinking": "solid",
"workbench.activityBar.visible": false
},
"description": "[ snip ]"
}
}
}
},
extension.js
// In the "main" method that runs when a command is activated:
const config = vscode.workspace.getConfiguration("toggleSettingsChanges");
const settingsToToggle = config.get("settingsToToggle");
const inspectedSettingsToToggle = config.inspect("settingsToToggle");
console.log("settingsToToggle:", JSON.stringify(settingsToToggle), "\n\n")
console.log("inspected settingsToToggle:", JSON.stringify(inspectedSettingsToToggle), "\n\n")
return;
In the Extension Host instance, I can tweak and adjust the settings, to include this:
User or Workspace Settings JSON
// ...
"toggleSettingsChanges.settingsToToggle": {
"editor.fontSize": 11,
"pumpkins_are_great": true
},
In the console output, I'm seeing the following:
settingsToToggle: {"window.zoomLevel":2,"editor.fontSize":11,"terminal.integrated.fontSize":16,"scm.diffDecorations":"none","workbench.statusBar.visible":false,"editor.cursorBlinking":"solid","workbench.activityBar.visible":false,"pumpkins_are_great":true}
inspected settingsToToggle: {"key":"toggleSettingsChanges.settingsToToggle","defaultValue":{"window.zoomLevel":2,"editor.fontSize":22,"terminal.integrated.fontSize":16,"scm.diffDecorations":"none","workbench.statusBar.visible":false,"editor.cursorBlinking":"solid","workbench.activityBar.visible":false},"globalValue":{"editor.fontSize":11,"pumpkins_are_great":true}}
For the settingsToToggle line, I expected to see only the following settings:
{"editor.fontSize":11,"pumpkins_are_great":true}
It seems that if you provide an object default, any configuration provided is merged with that object, instead of replacing it entirely.
Is that the case? Have I missed this in the documentation?
It seems to me that a value (even an object) would be overwritten, and not simply merged.
The documentation may have been updated since this question was posted. The way it's written now, seems pretty clear to me. I'm writing because I feel I have found a discrepancy in the API, which may help out the OP.
Reference
Note: Only object value types are merged and all other value types are overridden.
-- VS Code API - WorkspaceConfiguration
Additional information
I want my default values to be merged with the user settings, as is described above. I was confused by seeing my defaults overriden. This question helped me understand what is happening. I'll share my approach since OP may be interested. My observations:
Default values provided in package.json are merged with user settings, as described in the documentation (link above).
Default values passed programmatically with WorkspaceConfiguration.get(section, defaultValue) do not exhibit the merging behavior. It's not clear if this is intentional or not. Update: this behavior is working as intended, reference #105598.
I have created a Activity Stored Procedure1.
it is running fine when i manually run.
it is running fine with Trigger Now.
but schedule trigger not running. I have only one activity in my pipeline Stored Procedure1
below is trigger code
{
"name": "trigger1",
"properties": {
"runtimeState": "Started",
"pipelines": [
{
"pipelineReference": {
"referenceName": "pipeline3",
"type": "PipelineReference"
}
}
],
"type": "ScheduleTrigger",
"typeProperties": {
"recurrence": {
"frequency": "Minute",
"interval": 6,
"startTime": "2019-01-10T20:47:00.000Z",
"timeZone": "UTC"
}
}
}
Based on official document, I think your trigger did not be triggered because of the limitation of Azure Data Factory.
Official statement:
The parameters property is a mandatory property of the pipelines
element. If your pipeline doesn't take any parameters, you must
include an empty JSON definition for the parameters property.
So, according to your code, you missed the parameters property. Please add it even though you don't have it, and the trigger will be executed normally.
Just adding this if it helps to someone...
I had the similar issue and tried this option of creating dummy variable in pipeline, but the issue was when I deploy the code to other environment(dev-->test/ppe/prod), i was getting the error like 'instance of an object not set properly' (and I have azure function activity in my adf pipeline, and this is where i was getting this error). So I tried creating dummy header under 'settings' in azure function activity and deployed,trigger worked this time as expected. Hope this helps.
I'm developing an extension to VSTS. The tasks are written in JavaScript.
In the extension, there is a string input field. In this input, the user can enter a path in his file system. The user can use the agent's environment variables, such as ${'Build.SourcesDirectory'}. During the task, I read the input variable by getInput() function of vsts-task-lib/task library.
The problem: I need to get the raw string input in order to process it during the task. For example, instead of c:\agent\_work\1\s i'd prefer to get ${'Build.SourcesDirectory'}.
This is the input field in
task.json:
{
"name": "myName",
"type": "multiLine",
"label": "My Label",
"required": true,
"properties": {
"resizable": "true",
"rows": "10",
"maxLength": "10000"
}
}
The variable value is replaced by the system as soon as the build start. So getInput() method can only get its value rather than the original string. If you do want that strings, call the Rest API to parse the build definition settings.
I'm often using VS Code for Html/Css/Js development. I'm often using the following task (from other SO post) to open HTML page in browser:
{
"version": "0.1.0",
"command": "explorer",
"windows": {
"command": "explorer.exe"
},
"args": ["${file}"]
}
Is there a way to add this task as default one for all folders?
The short answer is "no".
The slightly longer answer is, "no, but they are thinking about ways this can be done" as demonstrated in this issue.
A workaround is to add a snippet that you can easily add to tasks.json in new projects. Go to File > Preferences > User Snippets > json and add something like this:
"Explorer Task": {
"prefix": "expTask",
"body": [
'{',
'\t"version": "0.1.0",',
'\t"command": "explorer",',
'\t"windows": {',
'\t\t"command": "explorer.exe"',
'\t},',
'\t"args": ["${file}"]',
'}'
],
"description": "Explorer task that I use so often"
},
Now when you go to tasks.json in any new project, you type expTask (or whatever you name it) and you can easily drop this in.