we have started getting the following error in one of our function apps:
Invalid script file name configuration. The 'scriptFile' property is set to a file that does not exist.
This is a recent development and we have been refactoring the code and configuration so we have obviously done something wrong. I have searched for the error and I keep finding fixes for typescript or javascript. We have written our functions in C# but not sure if either of those two are involved in producing the file.
function.json:
{
"generatedBy": "Microsoft.NET.Sdk.Functions-1.0.29",
"configurationSource": "attributes",
"bindings": [
{
"type": "queueTrigger",
"queueName": "%CampaignQueueName%",
"name": "message"
}
],
"disabled": false,
"scriptFile": "../bin/CampaignIngestion.Functions.dll",
"entryPoint": "CampaignIngestion.Functions.CampaignSplitterFunction.Run"
}
I have checked the path in one of the function.json files and it seems to be correct as I can find the file through Kudo's powershell console.
I suspect we have broken this with some of the configuration changes but we need help to identify where and how to fix this. Any suggestions as to what is causing this please?
Related
I'm trying - for the sake of learning - to write tasks.json & launch.json for VSCode to build this project: ExportableDataGrid
There are two .csproj - one builds a 'Library' and the other a 'WinExe' which depends on the library.
The build is successful, but the Debugger doesn't launch the .exe and has this error:
Error processing 'configurationDone' request. Unknown Error: 0x80131c30
With this cli:
dotnet build Mm.ExportableDataGrid\Mm.ExportableDataGrid.csproj
dotnet build Mm.ExportableDataGrid.Wpf\Mm.ExportableDataGrid.Wpf.csproj
I get these errors:
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\mm.exportabledatagrid.wpf.csf.csproj]
C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\MainWindow.xaml.cs(13,13): error CS0103: The name 'InitializeComponent' does not exist in the current context [C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\mm.exportabledatagrid.wpf.csproj]
C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\MainWindow.xaml.cs(52,13): error CS0103: The name 'dataGrid' does not exist in the current context [C:\Users\userid\C-Sharp Prp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\mm.exportabledatagrid.wpf.csproj]
Both launch.json and tasks.json are in a root folder containing both folders from the github archive.
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Custom .NET Launcher",
"type": "clr",
"request": "launch",
"preLaunchTask": "buildExe",
"program": "${workspaceFolder}/Mm.ExportableDataGrid.Wpf/bin/Debug/Mm.ExportableDataGrid.Wpf.exe",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label":"buildDll",
"type":"shell",
"command":"C:/\"Program Files (x86)/\"Microsoft Visual Studio\"/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe",
"presentation":{
"clear":true
},
"args":[
"Mm.ExportableDataGrid\\Mm.ExportableDataGrid.csproj",
"/t:Build",
"/p:Configuration=Debug",
"/p:Platform=\"AnyCPU\""
]
},
{
"label":"buildExe",
"type":"shell",
"command":"C:/\"Program Files (x86)/\"Microsoft Visual Studio\"/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe",
"presentation":{
"clear":true
},
"dependsOn":"buildDll",
"args":[
"Mm.ExportableDataGrid.Wpf\\Mm.ExportableDataGrid.Wpf.csproj",
"/t:Build",
"/p:Configuration=Debug",
"/p:Platform=\"AnyCPU\""
]
}
]
}
Despite much reading I cannot figure out what is going on here.
How do I debug the 0x80131c30 error?
Why do I get the CS5001 error?
Also - I am able to Run Without Debugging, no issues. Seems to be an issue with attaching the debugger.
I just found the issue after weeks having trouble with it.
The fix is to create a "My_Project.runsettings" file specifying "x64" and refer to it in the settings.json of you solution with "omnisharp.testRunSettings":"Path_To_My_File\My_Project.runsettings"
Please see my answer on github for the detailed explanation : https://github.com/OmniSharp/omnisharp-vscode/issues/4361#issuecomment-858540496
I am just getting started in C# (and coding in general), following a very basic setup tutorial on YouTube. I am trying to run the simple bit of code generated from clicking Terminal>New Terminal:
using System;
namespace Program1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
From what I understand, this should run just about instantly (it runs perfectly for the tutorial instructor).
I Also get the following problem (CS0579) (now resolved thanks to a comment):
Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute'
The file with this problem looks like this:
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
The launch.json file has not been altered from the auto-generated file:
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Program1.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
I am running VSCode 1.47.2 and .NET Core SDK 3.1.302
If you've just started this project, and all it consists of is the above code, I'd recommend closing visual studio, deleting the project folder, and starting over. Seems like something got messed up and you're going to take a lot longer figuring out what it was than just starting over.
I know that sounds like the lazy way to do it, but with just a short 'hello world' program, you shouldn't need to take hours debugging it. Just start over.
Is it possible to write the output of snippet to the line above the current line?
I'm trying to create a snippet where you select an element name from csharp file and it inserts a Summary section above the element.
Snippet:
"CSharpSummarySelected": {
"prefix": "c#-summary-selected",
"body": [
"/// <summary>",
"/// ${1:$TM_SELECTED_TEXT}",
"/// </summary>",
"/// <returns>${2:returns}</returns>"
],
"description": "Inserts Summary for component with selected text as name in C# files"
}
Microsoft Visual Studio product includes a code snippet manager.
But with Visual Studio Code, you will need to use an extension. You will one in the Visual Studio Marketplace C# Snippets for Visual Studio Code by Jorge Serrano.
The author has also released the source code on Github https://github.com/J0rgeSerran0/vscode-csharp-snippets. This provide a great learning opportunity for other developer to wrote their extensions.
I don't think you can insert a snippet above text without using a macro or an extension - except in the trivial case where the selection was the only thing on the line, which I assume is not the case for you.
Using some macro extension, here multi-command, put this into your settings.json:
"multiCommand.commands": [
{
"command": "multiCommand.cSharpSummary",
"sequence": [
"editor.action.clipboardCopyAction",
"editor.action.insertLineBefore",
{
"command": "editor.action.insertSnippet",
"args": {
"name": "CSharpSummarySelected"
}
}
]
}
]
and your snippet into some snippets file:
"CSharpSummarySelected": {
"prefix": "c#-summary-selected",
"body": [
"/// <summary>",
// "/// ${1:$TM_SELECTED_TEXT}",
"/// ${1:$CLIPBOARD}", // this works witheditor.action.clipboardCopyAction, select only
"/// </summary>",
"/// <returns>${2:returns}</returns>"
],
"description": "Inserts Summary for component with selected text as name in C# files"
}
NOTE: my snippet uses $CLIPBOARD instead of $TM_SELECTED_TEXT. This is because the act of inserting a line above your selected text de-selects your selection (i.e., you lose your selection by inserting the line above).
You only have to select your variable, not actually copy it - the macro will take care of the copy action for you. But the clipBoard will now have your variable on it instead of whatever it had before - this may or may not be acceptable to you - in a macro I think it is unavoidable.
Now the macro will be triggered not with a prefix but with a keybinding. In keybindings.json:
{
"key": "ctrl+alt+b", // whatever keybinding you choose
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.cSharpSummary" }
},
Now when you select some text and trigger the macro with the keybinding your snippet will be inserted above that line with your desired tabstops. See demo:
After moving my .NET Core project into a subfolder in the solution I am no longer able to Debug it using VS Code.
If I move tasks.json and launch.json into the project folder and open VS Code there I am able to debug, but I would like to be able to open the entire solution in VS Code.
The error message I am getting is this:
MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
The error seems to state that my task runner can no longer find my project, so I tried adding this to tasks.json:
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [ ],
"isBuildCommand": true,
"showOutput": "silent",
"problemMatcher": "$msCompile"
}
],
// My addition
"options": {
"cwd": "${workspaceRoot}/myProjectFolder"
}
}
Doing this I am able to start the task, but I then get the following error:
Exception thrown: 'System.IO.FileNotFoundException' in
Microsoft.Extensions.Configuration.FileExtensions.dll
How do I configure the .NET Core debugger to be able to run a project that resides in a sub folder?
The problem is your tasks.json, you should copy your subfolder .vscode/tasks.json in the parent directory.
When you create your tasks.json from the parent directory, it make a tasks.json like as your tasks.json example.
But if you copy the tasks.json created in the subfolder It should be some like this:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/<change to your subfolder>/<your project>.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
So there is the .csproj file, it say in the error.
The reason for the FileNotFoundException pointed by mrtedweb, the program not finding the appsettings.json can be solved without changing the program code.
Just edit launch.json, modifying the cwd configuration to point to the project subfolder instead of the root workspace which is the default, from
cwd: ${workspaceRoot} to, ${workspaceRoot}/TheProject.
// C:\Solution\.vscode\launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/TheProject/bin/Debug/netcoreapp1.1/TheProject.dll",
"args": [],
"cwd": "${workspaceRoot}/TheProject",
"stopAtEntry": false,
"console": "internalConsole",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:5050"
}
}
]
}
With this launch.json, it's possible to run the application from VS Code opening it from a root solution folder with the project inside a subfolder.
C:\Solution>code .
And it can also be run from the commandline without changing the paths in the program from the project subfolder.
C:\Solution\TheProject>dotnet run TheProject.csproj
It can no longer locate the appsettings.json file since the project was moved to a subfolder. This can be easily fixed in the StartUp.cs file by adding the following variable to the constructor:
var filePath = Path.Combine(env.ContentRootPath, "<project folder name>", "appsettings.json");
Note: You will need to specify the value for <project folder name>.
Then update the line that reads
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
to read:
.AddJsonFile(filePath, optional: false, reloadOnChange: true)
Also, verify the launch.json file is targeting the proper program file.
"program": "${workspaceRoot}/<project name>/bin/Debug/netcoreapp1.1/<program name>.dll"
Note: You will need to specify the values for <project name>, and <program name>.
I've just started working with DNX 1.0.0-rc1-update1 in VS2015. My first app is a 'Console Application (package)' project. Everything works, except NLog logging. I suspect it's because the NLog.config doesn't get copied to the output folder. How can I tell VS to copy this file to the output folder via project.json?
I've tried adding a 'resource' variable like this but it doesn't work:
project.json
...
"resource":"NLog.config",
...
EDIT 1:
I'm using dnx451 so compatibility is not an issue.
EDIT 2:
I added the following to project.json
"scripts": {
"postbuild": [
"%project:Directory%/../scripts/copy_resources.bat \\\"%project:Directory%\\\" \\\"%project:Directory%/../artifacts/bin/%project:Name%/%project:Version%/dnx451\\\""
]
}
copy_resources.bat
echo "Running script" >> C:\logs\log.txt
echo %1 >> C:\logs\log.txt
echo %2 >> C:\logs\log.txt
xcopy %1\NLog.config %2 /U /Y
There's nothing in the output window in VS to indicate that the script was actually run. Furthermore, log.txt is empty.
How can I debug the build process?
In the meantime, .NET Core RTM was published.
Now, the current way to get stuff copied to the output folder is using the buildOptions section in project.json.
There's the copyToOutput option which you can use like this:
Before:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
// more stuff
}
After:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true,
"copyToOutput": { "includeFiles": [ "NLog.config" ] }
},
// more stuff
}
Use copyToOutput inside buildOptions:
{
"buildOptions": {
"copyToOutput": "NLog.config"
}
}
or for multiple files declare an array:
{
"buildOptions": {
"copyToOutput": ["NLog.config", "testdata\\"]
}
}
To copy a directory remember to add the trailing \\.
By default all code files in a directory containing a project.json are
included in the project. You can control this with the include/exclude
sections of the project.json.
More info: http://docs.asp.net/en/latest/dnx/projects.html#including-excluding-files
You use the content section of project.json like this
{
"content": [
"NLog.config"
]
}
Now the documentation says that the file should have been copied by default as the content default if * (wildcard for all files), but you can force it with the explicit stating of the file you want in the content section.
I think it is broken in RC1. I was also looking how to get content files copied to the output folder, and found this issue that looks similar to what we are seeing.
As #Nkosi points out, the default for content is **/* (you can see via the docs link he provided, and also by the schema).
As for your postbuild step, you can get it going by "producing outputs".