Maybe one of you know how to solve the problem.
I want to run a written c# project ".NET 5.0 Framework" on a raspberry pi 4 in the mono ide. For this I insalled allready the ".Net 5.0 SDK Framework" from Microsoft homepage. In the settings of mono I set the right path to the "dotnet" folder. He found the ".NET Core SDK" (5.0.201) and ".NET Core Runtime" (5.0.4).
If I try now to build the project in the mono ide, I get the build error :
"/home/pi/dotnet5sdk/sdk/5.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(54,5): error MSB4186: Invalid call syntax for static method: "[MSBuild]: : GetTargetFrameworkIdentifier ('$ (TargetFramework)') ". Method '[MSBuild] :: GetTargetFrameworkIdentifier' not found. The following format must be used to call static methods: $ ([complete type name] :: method ()). Example: $ ([System.IO.Path] :: Combine (a, b)). Make sure that all parameters are defined, are of the correct type, and are specified in the correct order.
I also use xbuild instead of MSBuild.
I searched in a lot of forums but didn't found anything that could help me with this issue.
Did I forget some required settings?
https://github.com/mono/mono/issues/20250
Wait for an update to introduce latest MSBuild please. Without that .NET 5 projects can only be compiled by .NET 5 SDK dotnet command.
Related
How is this possible?
I installed .net sdk 6.0.405: dotnet-sdk-6.0.405-win-x64.exe
I can in windows terminal and power shell run: dotnet --version: 6.0.405 ✅
I CAN ALSO IN VSCODE IN ITS BUILTIN TERMINAL, run: dotnet --version: 6.0.405 ✅✅
But in the OUTPUT tab, choosing OmniSharp Log from the dropdown, it says:
[ERROR] A .NET 6 SDK for x86_64 was not found. Please install the latest x86_64 SDK from ...
I switched vscode explorer settings to use external terminal.
And this terminal setting to command prompt:
Terminal › Integrated › Default Profile: Windows
The default profile used on Windows. This setting will currently be ignored if either terminal.integrated.shell.windows or terminal.integrated.shellArgs.windows are set.
I have dotnet in the PATH (and it works in terminals and in vscode's terminal)
I restarted vscode, AND REINSTALLED the dotnettools "C# for Visual Studio Code (powered by OmniSharp)" extension. I went to the online store and from the right column under Resources I downloaded the ms-dotnettools.csharp-1.25.2#win32-x64.vsix to make sure I get the right one. And restarted vscode.
I tried this setting:
Omnisharp: Dotnet Path
Specified the path to a dotnet installation to use when "useModernNet" is set to true, instead of the default system one. This only influences the dotnet installation to use for hosting Omnisharp itself. Example: "/home/username/mycustomdotnetdirectory".
C:/Program Files/dotnet/sdk/6.0.405
And this setting:
Omnisharp: Sdk Path
Specifies the path to a .NET SDK installation to use for project loading instead of the highest version installed. Applies when "useModernNet" is set to true. Example: /home/username/dotnet/sdks/6.0.300.
C:/Program Files/dotnet/sdk/6.0.405
And restarted vscode. And now it says:
[ERROR] Error: Command failed: dotnet.exe --version
'dotnet.exe' is not recognized as an internal or external command,
operable program or batch file.
What? W H A T? lol
What could be wrong? Why isn't it saying where it expected to find it and what to do to locate it? Is there a setting to specify the dotnet.exe path to this C# extension? Does it need always-on internet or something? Does it have DRM? Does it need Edge installed? Wtf?🙂
🙃😭 I just need intellisense; and I've wasted 2h, on only microsoft-owned products.
#Microsoft 0/5 stars
Still don't know why it happens, but here's how to solve it:
The problem was from this: I like to keep all my visual studio code extensions as .vsix files locally in folders so I can remember and get them easily & offline. Sensible enough choice, and I had the correct ms-dotnettools.csharp-1.25.2#win32-x64.vsix for my platform.
But in VSCode, when I install this particular extension via VSIX, even though it succeeds, it can't find .net. If you instead install the extension "normally", ie via vscode's own download, it seems vscode does some extra configuration steps while installing, and probably sets the .net paths correctly or something. Because now it works.
So TL;DR: don't install ms-dotnettools.csharp via vsix, it seems bugged. 😶
Would love to see an answer explaining what's wrong / how to actually do via vsix; but I don't have any more time to debug this rn.
I've created a simple empty AWS Lambda function using .Net Core 2.1 :
Here is the folder structure :
(here is the csproj)
And a FunctionHandler which gets DI and invoke some dummy method :
Now let's run the "Mock Lambda Test Tool" , we can see that it works :
So where is the problem?
I've read here that 2.2 is supported :
This means you can now author Lambda functions using .NET Core 2.2 and
.NET Core 3.0 preview. Amazon.Lambda.RuntimeSupport is available as
source code on GitHub, or as a NuGet package.
And so , I've created a new empty lambda project but with 2.2 :
Here are the changes in the CSPROJ file
And here are the changes in the aws-lambda-tools-defaults.json file
Same code. But now when I run "Mock Lambda Test Tool" , I get an error :
AWS .NET Mock Lambda Test Tool (0.9.2) Unknown error occurred causing
process exit: Failed to find a deps.json file at
Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.Initialize(String
directory) in
E:\JenkinsWorkspaces\Lam\LambdaSandboxCoreCLRApi\Tools\LambdaTestTool\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs:line
50 at Amazon.Lambda.TestTool.Program.Main(String[] args) in
E:\JenkinsWorkspaces\Lam\LambdaSandboxCoreCLRApi\Tools\LambdaTestTool\Amazon.Lambda.TestTool\Program.cs:line
46 Press any key to exit
Here is the error :
Question:
Why is that? I didn't have any deps.json file in 2.1 .
So why do I need it in 2.2 ?
Also, what is this path appearing in the error: E:\JenkinsWorkspaces... ?
I don't have Jenkins nor something like it.
Well, I've found out the reason for this (I don't know why it happened at first place) but here it is. Bear with me.
When I've created a 2.1 lambda project, everything was OK. ( obviously)
The problem was with 2.2 projects ( targeting 2.2 & nugets of 2.2). (which shows the error as I show in my question)
So then I thought, what if I'll create a 2.1 project and then update(!) its nugets and change target to 2.2 ? .........it worked!
This was really weird. Because I expected it not to.
So then I thought, let's compare file system for a 2.2 project (which doesn't work), with a 2.1 project that was updated to a 2.2 project (which does work, surprisingly).
On the right side, it's the strict 2.2 projects (no update), on the left it's the project that was UPDATED to 2.2 :
I've noticed some .Net core 2.1 files that were in the upgrade but weren't in the strict 2.2 version, so I thought, how can I get those missing files ?
So I've changed (temporarily) the project target to 2.1 :
Then I've run build
This caused the files for the 2.1 folders to appear :
And now ............. , all OK !!! :
I am trying to set up my Ubuntu machine for dotnet core development. I've painstakingly installed Omnisharp-vim and set it to work with the OmniSharp-Roslyn server. I also have Syntastic and YouCompleteMe installed. I am getting syntax checking and Intellisense. I have two problems though:
Omnisharp-vim does not work without a solution file. Dotnet core projects don't have to have solutions files. How do I get around this?
I am getting syntax error for valid C# 6 code. For instance, it does not recognize the nameof operator.
How?
Add a valid global.json file to your root directory.
{}
Add two lines to the top of your vimrc file.
let g:OmniSharp_server_type = 'roslyn'
let g:OmniSharp_prefer_global_sln = 1
Why?
Those two OmniSharp settings tell omnisharp-vim to use Roslyn and to use the directory that contains a global.json file.
Here is the OmniSharp.vim file source-code that uses those variables.
if g:OmniSharp_server_type ==# 'roslyn' && g:OmniSharp_prefer_global_sln
let global_solution_files = s:globpath(dir, 'global.json')
call filter(global_solution_files, 'filereadable(v:val)')
if !empty(global_solution_files)
let solution_files = [dir]
break
endif
endif
If that does not work...
Try starting OmniSharp manually from the command line:
omnisharp-vim\omnisharp-roslyn\artifacts\scripts\OmniSharp.cmd -s C:\temp\
The C:\temp\ directory contains a new .NET Core project with a valid global.json file.
I'm trying to use Gst# (which is the C# bindings for GStreamer) on Mac, but autotools keeps failing with these last few lines:
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for pkg-config... /opt/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... dyld: Library not loaded: /opt/local/lib/libiconv.2.dylib
Referenced from: /opt/local/bin/pkg-config
Reason: Incompatible library version: pkg-config requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0
./configure: line 11558: 15968 Trace/BPT trap: 5 $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version
no
checking for MONO_DEPENDENCY... no
checking for csc.exe... no
configure: error: You need to install either mono or .Net
Saying that Mono isn't installed is nonsense; how can I fix this and get it to succeed? If it helps, I installed Mono through the Mac installer, not Macports, though Macports is installed.
Your mono installation is not in $PKG_CONFIG_PATH, and that's why pkg-config cannot find the .pc files for mono.
You need to add the directory to your $PKG_CONFIG_PATH environment variable. The directory should be at /Library/Frameworks/Mono.framework/Versions/VERSIONNUMBER/lib/pkgconfig/
The error is explained quite clearly:
Reason: Incompatible library version: pkg-config requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0
In order to update to a newer version I would suggest trying this in Terminal:
sudo port -n upgrade --force libiconv
More information here.
I'm new to linux and mono. I installed mono to a new Raspberry Pi machine using
sudo apt-get install mono-complete.
I also did the update and upgrade using apt-get.
I then followed the helloWorld examples in the Mono Basics page in mono-project website:
http://www.mono-project.com/docs/getting-started/mono-basics/
I managed to build and run the first 'Console Hello World' example using the following:
mcs hello.cs
mono hello.exe
However, when I tried the next example 'Winforms Hello World', I encountered the following error when running 'mcs hello.cs -pkg:dotnet':
error CS0006: Metadata file 'cscompmgd.dll' could not be found
However, it works if i use gmcs instead of mcs.
I googled here and there but no luck.
I can find a link to this file 'cscompmgd.dll' in '/usr/lib/mono/2.0' directory in my Raspberry Pi.
The installed mono version is 3.2.8 (returned by using 'mono --version').
Does anyone know why it works with gmcs but it doesn't work with mcs?
Thank you.
Solved by adding the -lib: option like this:
mcs helloWinforms.cs -pkg:dotnet -lib:/usr/lib/mono/2.0
Solution with adding
-lib:/usr/lib/mono/2.0
was not the best in my case (it broke a dependency on some 4.0 elements, specifically 'System.Threading').
Dirty, but works
Another, very dirty solution is to copy the
/usr/lib/mono/2.0/cscompmgd.dll
to your project folder (or wherever the Makefile is) and add
-r:cscompmgd.dll
when compiling (or add the filename after list of other included libraries specified by '-r').
There is probably a way to do that without copying the file, but that is beyond my capabilities.
So you end up with:
mcs helloWinforms.cs -pkg:dotnet -r:cscompmgd.dll