C# LSP autocompletion client for neovim / vim8 - c#

I've tried several ways to make it work but there seems to be no easy way. Yes, there are a ton of plugins, configurations. But they do not work right as per Oct 2019.
OmniSharp-Vim client needs configuration, it covers only C# and it lists plugins integration that does not work anymore (try choosing it for linting in ALE).
YouCompeleteMe should work but it is large and seems bloated.
Deoplete don't have source for C# and configurations I found are out of date.
Coc.nvim does not even list C# and 'unofficial' configurations have issues (like this). Besides Coc.nvim seems to be an alien from VS Code.
LanguageClient-neovim I didn't find sensible configuration and it seems because C# LSP server needs .sln file.
So this seems that csharpers should go to VS (or Rider) and that is when MS proposed LSP. How do you make IDE like from nvim to work with C#?
Basically the client should start server like this and use LSP.
~/.cache/omnisharp-vim/omnisharp-roslyn/run -s <PATH TO SLN OR DIR>

I just got omnisharp / ale working successfully with a clean install. You may want to completely uninstall omnisharp (~\AppData\Local\omnisharp-vim or ~/.omnisharp) just in case you have old versions.
You didn't mention your OS; I have this working in both Windows 10 and Mac OS. If you're using Mac OS make sure you brew install libuv first.
My Environment
Windows 10 (v1903) and Mac OS 10.14.6
Vim 8.1.2244
dotnet core 3.1 - I'd expect 3.0 to work as well
Instructions
First off, I'm using vim-plug as my plugin manager to handle installation. I installed it in both Windows and Mac OS using the bash/powershell snippets in vim-plug's README.
Then I added the following to my vimrc (~\_vimrc on Windows, ~/.vimrc on Mac OS):
"vim-plug config
call plug#begin()
Plug 'OmniSharp/omnisharp-vim'
Plug 'dense-analysis/ale'
call plug#end()
" plugin config
let g:OmniSharp_server_stdio = 1
Restart vim, and run :PlugInstall. It will clone omnisharp and ale for you.
Next, find some C# solution, and ensure the solution builds at the commandline (e.g. dotnet build should complete without errors). You also need a SLN file if you don't already have one (dotnet new sln and then dotnet sln add MyProj.csproj)
Choose a C# file and open it in vim. You should see the following notification:
If the install doesn't autostart, you can start it with :OmniSharpInstall. The install takes a minute or two of downloading in a terminal window. After the installation is complete, reopen vim and execute :cd \path\to\my\solution to ensure the working directory inside vim is correct. Then open a file with e.g. :e MyProj\Program.cs.
The server will be started automatically; don't manually start it. I get a lot of syntax errors for the first few seconds while the server is starting, after that I don't have any errors.
To pull up the autocomplete, type something like Console. then hit Ctrl-x o:
The above screenshot has vim-airline for the bottom bar -- that's not part of omnisharp and isn't required.
The above screenshots are Windows, but it's also working fine in Mac OS:
My full vimrc is available here and the source code I'm testing with is available here.

So far here is my setting for this using Deoplete, OmniSharp and ALE (full config at https://github.com/artkpv/dotfiles/blob/master/.config/nvim/vimrc) :
" Install Deoplete and OmniSharp:
" - OmniSharp/omnisharp-vim " for LSP support (like start OmniSharp server) and code actions, etc
" - Shougo/deoplete.nvim " for better autocompletion
" - dense-analysis/ale " for highlights
function SetCSSettings()
" Use deoplete.
call deoplete#enable()
" Use smartcase.
call deoplete#custom#option('smart_case', v:true)
" Use OmniSharp-vim omnifunc
call deoplete#custom#source('omni', 'functions', { 'cs': 'OmniSharp#Complete' })
" Set how Deoplete filters omnifunc output.
call deoplete#custom#var('omni', 'input_patterns', {
\ 'cs': '[^. *\t]\.\w*',
\})
" ... then goes your mappings for :OmniSharp* functions, see its doc
endfunction
augroup csharp_commands
autocmd!
" Use smartcase.
" call deoplete#custom#option('smart_case', v:true)
autocmd FileType cs call SetCSSettings()
augroup END

Related

Process terminated. Couldn't find a valid ICU package installed on the system in Asp.Net Core 3 - ubuntu

I am trying to run a Asp.Net Core 3 application in Ubuntu 19.10 thru terminal using dotnet run command but it does not seem to work. I get this error.
Process terminated. Couldn't find a valid ICU package installed on the system.
Set the configuration flag System.Globalization.Invariant to true if you want
to run with no globalization support.
at System.Environment.FailFast(System.String)
at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode()
at System.Globalization.GlobalizationMode..cctor()
at System.Globalization.CultureData.CreateCultureWithInvariantData()
at System.Globalization.CultureData.get_Invariant()
at System.Globalization.CultureInfo..cctor()
at System.StringComparer..cctor()
at System.StringComparer.get_OrdinalIgnoreCase()
at Microsoft.Extensions.Configuration.ConfigurationProvider..ctor()
at Microsoft.Extensions.Configuration.EnvironmentVariables.EnvironmentVariablesConfigurationSource.Build(Microsoft.Extensions.Configuration.IConfigurationBuilder)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder..ctor(Microsoft.Extensions.Hosting.IHostBuilder)
at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(Microsoft.Extensions.Hosting.IHostBuilder, System.Action'1<Microsoft.AspNetCore.Hosting.IWebHostBuilder>)
at Microsoft.Extensions.Hosting.GenericHostBuilderExtensions.ConfigureWebHostDefaults(Microsoft.Extensions.Hosting.IHostBuilder, System.Action'1<Microsoft.AspNetCore.Hosting.IWebHostBuilder>)
at WebApplication.Program.CreateHostBuilder(System.String[])
at WebApplication.Program.Main(System.String[])
I installed the dotnet core sdk using the ubuntu store and after that I also installed Rider IDE.
The weird thing here is that when I run the app using Rider it runs fine, the only issue is using terminal dotnet core commands.
Does anybody know what might be the issue ?
The application is created using Rider. I don't think that this plays a role but just as a side fact.
I know there are also other ways to install dotnet core in ubuntu but since the sdk is available in the ubuntu story I thought it should work out of the box and of course its an easier choice.
Also tried this one but does not seem to work for me. Still the same issue happens after running the commands.
The alternative solution as described in Microsoft documentation is to set environment variable before running your app
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
If you want to run with no globalization support, you need to get "System.Globalization.Invariant": true into your published output AppName.runtimeconfig.json file as shown in the example below:
{
"runtimeOptions": {
"tfm": "netcoreapp3.0",
"configProperties": {
"System.GC.Server": true,
"System.Globalization.Invariant": true
}
}
}
You can add it manually every time you deploy by adding or updating the AppName.runtimeconfig.json file. Better yet, add it once to a runtimeconfig.template.json file like this:
{
"configProperties": {
"System.Globalization.Invariant": true
}
}
Make sure that runtimeconfig.template.json is included in build/publish.
It seem the package libicu63 will provide the ico support for dotnet on Linux, at least on Debian'ish distros.
Update:
And it seems it's "missing" when doing a small installing of Debian (i.e. deselect all applications/system-options in the installation program, except for SSH server)
The trick around it on Ubuntu 20.04 based on this thread https://github.com/dotnet/core/issues/2186#issuecomment-671105420
$export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
Yes. When installing Github action in Debian. It is also required.
As the response from MrCalvin,
sudo apt-get update && sudo apt-get install -qqq libicu63 resolve my issue.
edit your .bashrc file by adding the following line, e.g.:
nano ~/.bashrc
add
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
Ctrl+o, Ctrl+x
restart terminal and run pwsh again
I had this issue while trying to run Umbraco version 9.2.0. Fiddling with System.Globalization.Invariant was not a good solution as it broke globalization in the backoffice. This issue has been solved in v9.4: https://github.com/umbraco/Umbraco-CMS/pull/11961
I didn't want to upgrade my Umbraco version to solve this, so I just copied the change in that commit to my project.
Simply go into the .csproj file of your web project and change the ICU package reference lines to:
<!-- Force windows to use ICU. Otherwise Windows 10 2019H1+ will do it, but older windows 10 and most if not all winodws servers will run NLS -->
<ItemGroup>
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
<RuntimeHostConfigurationOption
Condition="$(RuntimeIdentifier.StartsWith('linux')) Or $(RuntimeIdentifier.StartsWith('win')) Or ('$(RuntimeIdentifier)' == '' And !$([MSBuild]::IsOSPlatform('osx')))"
Include="System.Globalization.AppLocalIcu"
Value="68.2.0.9" />
</ItemGroup>
In my case, I followed the Windows documentation to install SDK dependencies and Runtime, watch out for the corresponding version to each Linux distribution to avoid compatibility issues.
This helped me override the default ICU version to the one that's installed on the machine running arch linux.
export CLR_ICU_VERSION_OVERRIDE=$(pacman -Q icu | awk '{split($0,a," ");print a[2]}' | awk '{split($0,a,"-");print a[1]}')

Make changes to registry before installation of a program

Ok, I created an installation file for my program with InstallShield(software). I was not able to successfully install the program until I made changes to the registry as described here .NET 4 fails to install because SECUREREPAIR fails to CreateContentHash of file SetupResources.dll: for computing hash Error: 997. After making the changes to the registry, I am able to install my program. So, the registry changes are to be made before running my installer file. Can I not embed that .reg file somewhere from the InstallShield while creating the installer file so that the .reg file runs before my actual installation begins?
You can create a custom action in a script to update the registry and add to the sequence. Below is a rough example (won't work off without some tweaking).
Then add to your sequence before ISInstallPrerquisites in the UI Sequence.
STRING svCmd;
STRING svCmdPath;
begin
'For DWORD:
svCmd = "reg add " + KeyName + " /v " + ValueName + " /t REG_DWORD /d " + dataValue + " /f";
'For String:
svCmd = "reg add " + KeyName + " /v " + ValueName + " /t REG_SZ /d " + dataValue + " /f";
svCmdPath = "cmd";
LaunchAppAndWait(svCmdPath, "/c \"" + svCmd +"\"", LAAW_OPTION_HIDDEN | LAAW_OPTION_WAIT);
Does this problem occur on all computers, or just some? What OS?
What is your anti-virus softare, security suite?
Are you on a locked-down corporate SOE? (Standard Operating Environment).
Are there custom policies?
Are you using mandatory (or temporary) profiles?
Pre-Requisite: If this is the official Microsoft .NET 4 runtime installer which falls over, then I would exclude it from my own setup and deliver it as a pre-requisite alongside my main installer, or I would simply point to the web-page to download the latest version of that runtime. I much prefer the latter option since what you deliver with your package could be outdated in no time as new security hotfixes become available. Crucially: most people will probably have this runtime installed by now?
Windows Update: I might even tell the user to install via Windows Update, but that is more of a manual process with more steps. Isn't .NET 4 a mandatory Windows Update install by now?
Corporate Users: Corporate packagers will appreciate the separation of runtimes from your own package seeing as much time is spent taking pre-requisite packages out of vendor packages. They simply need some one-page documentation telling them what runtime is needed. They will have the right one pre-packaged according to their own corporate standard - and debugged of issues like you mention. There is not much need to combat the runtime setup.
Real World: You can deliver a *.reg file along with your .NET 4 installer file with a brief README.txt describing the problem you mention. Then they can deal with it if they have to, and if the problem is not seen then you avoid all the fuss. Then you add a LaunchCondition to your main setup to prevent its installation unless .NET 4 is installed.
Installer softwares usually (always ? Well instalShield has one at least) have a "Registry" feature where you can define the registry hierarchy/entries/values you wanna add.
No need of any script or reg file. All values are set up before the installation they are linked with.
Anyway, you are unlikely asked to find a work around as InstallShield already deal with it for you. Just set it up in the installer.

Asp.Net Core - Error cannot execute binary file on published (Ubuntu 14.04) web application with supervisor

I am not sure if this is the right place to ask, but here it is: I created an ASP.NET Core web application, and copied all the files on my Ubuntu 14.04 server. I can compile and run without a problem, but now I want this application/web site to run permanently.
I followed all the steps described here https://docs.asp.net/en/latest/publishing/linuxproduction.html, installed nginx as reverse proxy to run with apache, and all of this run perfectly well.
BUT, trying to use supervisor and start the app from it, I systematically get an error /usr/bin/dotnet cannot execute binary file. But, if I move to be in the directory where the application is published, and manually type dotnet appname.dll it does start without a glitch.
I am not sure where to look to get this to work with supervisor. Thanks for your help (and if this question should be somewhere else, let me know)
I finally solved my problem, replacing the equivalent of the line command=bash /usr/bin/dotnet /var/aspnetcore/HelloMVC/HelloMVC.dll as described in https://docs.asp.net/en/latest/publishing/linuxproduction.html under "Configuring Supervisor" by a little script, far from perfect as I get a Warning: HOME environment variable not set.
Anyway, here is the script:
#!/bin/bash
cd /var/aspnetcore/foesuivi/
dotnet FoESuivi.dll
cd $HOME
As a windows programmer, I don't know much about bash scripting, but I certainly can see that I would need to give a value to $HOME before the cd command.
Anyway, after doing a chmod +x to the sh file, and replacing the command= with the full name of the sh file, it is now working, I can reboot and my site is immediately available.

Programmatically enable (install) IIS

Sometimes there is a PC that doesn't have IIS. Either it disabled or either it not installed. In this case I need to enable it myself according to those steps.
I'm trying to create application that will check if IIS is enabled (installed), and if not it will enable (install) it.
I tried to install IIS using .msi files from here, but it asking me to follow those stpes before the installation.
I tried to use Advanced Installer but apparently it installing the IIS 8.0 Express but still it keeps the IIS disabled.
What I need to do to enable IIS programmatically? It is also acceptable if I'll need to run an IIS installation file to make it done (I didn't find the right one).
You can install IIS via the command line. The following command will install IIS on Windows 8 (you can edit this to add/remove certain features. It's just a command I've used in the past):
PkgMgr:
start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-ApplicationDevelopment;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-NetFxExtensibility45;IIS-ASPNET45;IIS-NetFxExtensibility;IIS-ASPNET;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-RequestMonitor;IIS-Security;IIS-RequestFiltering;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;IIS-ManagementConsole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI
DISM:
START /WAIT DISM /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-ASP /FeatureName:IIS-ASPNET /FeatureName:IIS-BasicAuthentication /FeatureName:IIS-CGI /FeatureName:IIS-ClientCertificateMappingAuthentication /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-CustomLogging /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DigestAuthentication /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-FTPExtensibility /FeatureName:IIS-FTPServer /FeatureName:IIS-FTPSvc /FeatureName:IIS-HealthAndDiagnostics /FeatureName:IIS-HostableWebCore /FeatureName:IIS-HttpCompressionDynamic /FeatureName:IIS-HttpCompressionStatic /FeatureName:IIS-HttpErrors /FeatureName:IIS-HttpLogging /FeatureName:IIS-HttpRedirect /FeatureName:IIS-HttpTracing /FeatureName:IIS-IIS6ManagementCompatibility /FeatureName:IIS-IISCertificateMappingAuthentication /FeatureName:IIS-IPSecurity /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /FeatureName:IIS-LegacyScripts /FeatureName:IIS-LegacySnapIn /FeatureName:IIS-LoggingLibraries /FeatureName:IIS-ManagementConsole /FeatureName:IIS-ManagementScriptingTools /FeatureName:IIS-ManagementService /FeatureName:IIS-Metabase /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ODBCLogging /FeatureName:IIS-Performance /FeatureName:IIS-RequestFiltering /FeatureName:IIS-RequestMonitor /FeatureName:IIS-Security /FeatureName:IIS-ServerSideIncludes /FeatureName:IIS-StaticContent /FeatureName:IIS-URLAuthorization /FeatureName:IIS-WebDAV /FeatureName:IIS-WebServer /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-WebServerRole /FeatureName:IIS-WindowsAuthentication /FeatureName:IIS-WMICompatibility /FeatureName:WAS-ConfigurationAPI /FeatureName:WAS-NetFxEnvironment /FeatureName:WAS-ProcessModel /FeatureName:WAS-WindowsActivationService
In C#, you can create a Process that executes this command like so:
string command = "the above command";
ProcessStartInfo pStartInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
Process p = new Process();
p.StartInfo = pStartInfo;
p.Start();
You tag your question with InstallShield so I mention that later versions of InstallShield have support for enabling windows features:
Enabling Windows Roles and Features During a Suite/Advanced UI Installation
That said, I don't typically like to do this because you are really be intrusive with the configuration of the PC. I prefer to author a check that the required features are installed and block if they aren't.
Another thought is that ASP.NET 5.0 now supports self hosting as have other technologies such as WCF in the past. It might make sense to simply ditch the need for IIS and kill the problem that way.
Regarding your experience with Advanced Installer. You ended up with IIS Express installed because you used our predefined support for prerequisites. You should have been using the predefined support to install Windows Feature Bundles.
Using this support you can easily select which OS feature should be enabled and also set custom conditions. On our YouTube channel you can find examples/tutorials:
in the following example you see exactly how IIS is configured for enabling
here is also a more generic video, with a walkthrough over the built-in support from Advanced Installer for enabling Windows Features
You can install IIS from command line. First you need to enable ASP.NET 3.5:
IIS-ASPNET;IIS-NetFxExtensibility;NetFx4Extended-ASPNET45
or 4.5:
IIS-ASPNET45;IIS-NetFxExtensibility45;NetFx4Extended-ASPNET45
After that you can install IIS8, basically like IIS7. Checkout the IIS7 instalation http://www.iis.net/learn/install/installing-iis-7/installing-iis-from-the-command-line

SSIS Package failing because "script task is failing because the script is not precompiled"

I developed a pretty straight forward SSIS package (in VS2005 w/ .Net Framework V 2.0.50727 SP2) that gets a list of users to email, starts a for-each loop container and then executes a script task to retrieve user specific data and email it out to the user. When I run it on my dev box everything works great and runs as it should. However when I deploy the package to our production server running (Microsoft SQL Server 2005 - 9.00.5000.00 (X64) Standard Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2) ) the task fails.
The original error message is:
Executed as user: xxxxx. Microsoft (R) SQL Server Execute Package Utility Version 9.00.5000.00 for 64-bit Code: 0x00000009 Source: PackageName Description: The task cannot execute in 64-bit environment because the script is not pre-compiled. Please turn on the option to pre-compile the script in the task editor. End Error ... Error DTExec: The package execution returned DTSER_FAILURE (1).
After researching that extensively the interwebs suggested that I try:
running the package in 32bit by changing the execution property in the SQL job and by changing my RunIn64BitMode property from true to false
which fails because " Option "/X86" is not valid."
install the Microsoft Hotfix
which doesn't apply since I am already running on SP2
So after more research I find that I need to turn on "Please turn on the option to pre-compile the script in the task editor." SOURCE: ssis-dtsx DOT blogspot DOT com/2010/03/cannot-execute-in-64-bit-environment.html
Which entails:
Make sure that each script task has PreCompile = True
Open Script Task Editor, switch to Script tab and make sure that
PrecompileScriptIntoBinaryCode = True
Click on Design Script to open code editor (Visual Studio for Applications) and then choose it using File > Close and Return (VSA will recompile and store binary code in the package).
Build Project and copy to target location
However when I execute the package I immediately get the error:
Executed as user: xxxx. ...0.5000.00 for 64-bit Code: 0x00000008 Source: PackageName Description: The task is configured to pre-compile the script, but binary code is not found. Please visit the IDE in Script Task Editor by clicking Design Script button to cause binary code to be generated. End Error Code: 0x00000008 Source: GET PO infor and Email Description: Script could not be recompiled or run: Retrieving the COM class factory for component with CLSID...
So my final step was to turn DelayValidation property from False to True in the SSIS pkg, go into the design script to cause it to be rebuilt, then redeploy, and rerun and I still get the same error.
On searching the error I am directed to Microsoft HOT FIX which suggested that I download another hotfix.
I have not yet downloaded the hotfix, and would prefer not to if I can avoid it (our OPs team doesnt like running hotfixes mid day on production servers).
Go to the package, open the script component, then within Visual Studio (while looking at the code) click on BUILD. This will compile the package, if there are no issues preventing it from compiling. Then SAVE, go back and ensure that you click on "OKAY" and not "cancel", if you click on cancel then the whole thing reverts back.

Categories

Resources