I had an app I was developing in asp.net 4.5 and I wanted to move it to asp.net core and run on linux server (ubuntu).
I've been having a number of challanges and unfortunately current documentation is not helpful.
so...
How should I package the app?
The tech docs suggest building with the following command
dnu publish --runtime dnx-coreclr-linux-x64.1.0.0-rc1-update1
However I tried this on my local machine and it didn't have option to deploy linux version. When I run on server it comes up with a number of problems (covered later). So should I do this on server or get working on local machine.
NB: I read in another stack overflow question that as long as its coreclr it doesn't matter whether its win or linux?
I imagine after this is answered more questions will emerge..I've had so many issues with Core I'm wondering whether anybody has actually manged to deploy on app to Linux environment!
Any help would be greatly appreciated!
Update
To provide further information current runtimes on local machine are...
Active Version Runtime Architecture Location Alias
------ ------- ------- ------------ -------- -----
1.0.0-beta5 clr x64 C:\Users\Alex.dnx\runtimes
1.0.0-beta5 clr x86 C:\Users\Alex.dnx\runtimes
1.0.0-beta5 coreclr x64 C:\Users\Alex.dnx\runtimes
1.0.0-beta5 coreclr x86 C:\Users\Alex.dnx\runtimes
1.0.0-rc1-update1 clr x64 C:\Users\Alex.dnx\runtimes
1.0.0-rc1-update1 clr x86 C:\Users\Alex.dnx\runtimes
1.0.0-rc1-update1 coreclr x64 C:\Users\Alex.dnx\runtimes
1.0.0-rc1-update1 coreclr x86 C:\Users\Alex.dnx\runtimes
* 1.0.0-rc1-update2 clr x86 C:\Users\Alex.dnx\runtimes default
1.0.0-rc1-update2 coreclr x86 C:\Users\Alex.dnx\runtimes
I want to compile it as coreclr linux....however when I run the dnu publish command above it says runtime doesn't exist even though I update coreclr from nuget?
Do I need to specify an OS (linux or windows) when I build it or will a single published app run on both if its coreclr?
This runs fine when imported into Azure but doesn't work when deployed to linux
OK, here's how to:
Install Visual Studio 2017 (with .NET Core)
Create your project, and get it to compile on Windows
Once it compiles and runs, make sure you can publish it from Visual Studio
Once you can publish it from Visual Studio, close Visual Studio and do the following
open cmd.exe (Windows-Key + R)
cd "directory of your .sln file"
dotnet restore -r ubuntu.16.04-x64
dotnet build -r ubuntu.16.04-x64
dotnet publish -f netcoreapp1.1 -c Release -r ubuntu.16.04-x64
Your application should now be in folder bin/publish
A list of RIDs (-r) can be obtained here and here.
If you want to develop on Linux, run
apt-get install dotnet-dev-1.0.1
and the dotnet-utility should run on Linux.
Note that if you get
C:\Program
Files\dotnet\sdk\1.0.0\Microsoft.Common.CurrentVersion.targets(2865,5):
error MSB3554: Cannot write to the output file "C:\path\to\your\project\obj\Debug\netcoreapp1.1\YOUR_APP.Properties.Resources.resources".
Positive number required.
Build FAILED.
when you run the build or publish command, just run the command again.
Related
I have debian 11 installed in wsl2 on windows 10. I use the dotnet cli tools in visual studio and cmd windows but much prefer the linux syntax. The sdk commands are not exposed to wsl apparently as I get "bash: command dotnet not found" errors. Because WSL is essentially mapping linux commands to windows I don't think I should be installing the dotnet sdk again for linux, but can't really find any confirmation of that. Anyone here doing this who can advise? Just don't want to have to maintain two sets of the dotnet sdk if WSL does not require it.
The sdk commands are not exposed to wsl apparently as I get "bash: command dotnet not found" errors.
That's because WSL does not run Windows executables - it is, after all, a Linux subsystem.
I don't think I should be installing the dotnet sdk again for linux
You have two choices:
Use the Windows subsystem (drop WSL),
install the Linux applications you want to run.
I'm trying the following command for my .NET Core 3.1. Console application in the folder D:\core:
D:\core>dotnet publish -c Release –r ubuntu-x64 --self-contained true
And it gives an error:
MSBUILD : error MSB1008: Only one project can be specified. Switch:
ubuntu-x64
For switch syntax, type "MSBuild -help"
When I use these two commands separately they work perfectly fine, but I need Release for Ubuntu; when I don't try to specify Release for Ubuntu it creates Publish folder in Debug folder:
D:\core>dotnet publish –r ubuntu-x64 --self-contained true
D:\core>dotnet publish -c Release
To summarize, the problem is that I can't currently publish for Release for a specified OS.
You have a –r in your command. That's a em-dash (–) followed by an r. Have you tried using a normal dash/hyphen?
That works for me:
$ dotnet new console
Getting ready...
The template "Console Application" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on /home/omajid/temp/HelloWorld/HelloWorld.csproj...
Determining projects to restore...
Restored /home/omajid/temp/HelloWorld/HelloWorld.csproj (in 66 ms).
Restore succeeded.
$ dotnet publish -c Release -r ubuntu-x64 --self-contained true
Microsoft (R) Build Engine version 16.7.0-preview-20220-01+80e487bff for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
Restored /home/omajid/temp/HelloWorld/HelloWorld.csproj (in 16.86 sec).
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
HelloWorld -> /home/omajid/temp/HelloWorld/bin/Release/net5.0/ubuntu-x64/HelloWorld.dll
HelloWorld -> /home/omajid/temp/HelloWorld/bin/Release/net5.0/ubuntu-x64/publish/
Aside: you should use the linux-x64 runtime id rather than ubuntu-x64. linux-x64 is compatible with Ubuntu, but also many other distributions too.
I want to build Qt 5.12.4 on Windows 10 to have qtwebengine with proprietary codec for x86 applications but I get the 64-bit cross-building or native toolchain is required error as follows by running qmake .\qtwebengine -- -webengine-proprietary-codecs command.
Before running qmake command, I do the following steps:
Run Windows command prompt as Administrator. change directory to
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build
and run the following script:
vcvarsall.bat amd64_x86
I run this command because I want to build Qt WebEngine for x86 applications.
Change directory to
D:\Qt\Qt5.12.4\5.12.4\Src
and run the below command:
configure -webengine-proprietary-codecs
After this configuration setting, I got this result:
I installed these Qt webengine compile prerequisites:
-Python 2.7.15
-Bison, Flex from here
-GPerf(32bit) from here
-ActivePerl(64bit) from here
-LLVM(64bit) from here
-Visual Studio 2017
-Windows 10 SDK
I also add them to Windows path and restart my machine.
Besides, I also install MSVC 2015 64-bit, MSVC 2017 32-bit, MSVC 2017 64-bit, Sources, Qt WebEngine, and Qt Network Authorization components.
For windows I compiled qtwebengine with proprietary codecs using a bat file.
create qt5vars.bat. Paste below lines. Put this file in D:\Qt\Qt5.12.4\5.12.4\Src folder.
#echo off
REM Set up \Microsoft Visual Studio 2015, where <arch> is \c amd64, \c x86, etc.
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat" amd64_x86
REM Edit this location to point to the source code of Qt
SET _ROOT=D:\Qt\Qt5.12.4\5.12.4\Src
SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
SET _ROOT=
REM Keeps the command line open when this script is run.
cmd /k
Run the bat file.
Note: for qtwebengine compilation you need to enable the long path name support otherwise compilation may fail. To enable it use below link:
https://superuser.com/questions/1119883/windows-10-enable-ntfs-long-paths-policy-option-missing
I am creating a dotnet core 2.1 mvc application. I use win 10 as development machine but my prod server is Linux. Is it OK to Build it on Windows machine Or should I use a Linux box to build and then deploy on prod? Any execution or references or performance issues I might face?
You cannot build on Windows and deploy the same on to Linux.
For eg: dotnet build --runtime ubuntu.16.04-x64
Look into the following on how to build specific to linux
I have Visual Studio 2017 Community edition installed on my PC.
Recently I installed Qt5.10.1.
I generated a VS project from one of the example .pro files:
qmake -tp vc cube.pro
However when I open this VS project and build it I get the error:
The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".
How do I specify once for all that qmake shall target Windows SDK 10.0 instead of 8.1 so that I don't have to retarget manually each time I generate a VS project with qmake?
You cannot select Windows SDK version from qmake.
qmake expects that the environment is correctly setup before it is run.
If you use the command line directly, you will see the following message: Remember to call vcvarsall.bat to complete environment setup!.
This means that you have to run vcvarsall.bat with the proper options to setup the MSVC toolchain including your selected Windows SDK version.
Some examples:
# MSVC 2017 for 64 bit
vcvarsall.bat amd64
# MSVC 2017 for 64 bit using Windows 8.1 SDK
vcvarsall.bat amd64 8.1
# MSVC 2017 for 64 bit using Windows 10 SDK version 10.0.10240.0
vcvarsall.bat amd64 10.0.10240.0
# MSVC 2015 (installed with 2017 installer) for 64 bit using Windows 10 SDK version 10.0.10240.0
vcvarsall.bat amd64 10.0.10240.0 -vcvars_ver=14.0
And the help message from vcvarsall.bat:
Syntax:
vcvarsall.bat [arch] [platform_type] [winsdk_version] [-vcvars_ver=vc_version]
where :
[arch]: x86 | amd64 | x86_amd64 | x86_arm | x86_arm64 | amd64_x86 | amd64_arm | amd64_arm64
[platform_type]: {empty} | store | uwp
[winsdk_version] : full Windows 10 SDK number (e.g. 10.0.10240.0) or "8.1" to use the Windows 8.1 SDK.
[vc_version] : {none} for default VS 2017 VC++ compiler toolset |
"14.0" for VC++ 2015 Compiler Toolset |
"14.1x" for the latest 14.1x.yyyyy toolset installed (e.g. "14.11") |
"14.1x.yyyyy" for a specific full version number (e.g. 14.11.25503)
The store parameter sets environment variables to support Universal Windows Platform application
development and is an alias for 'uwp'.
For example:
vcvarsall.bat x86_amd64
vcvarsall.bat x86_amd64 10.0.10240.0
vcvarsall.bat x86_arm uwp 10.0.10240.0
vcvarsall.bat x86_arm onecore 10.0.10240.0 -vcvars_ver=14.0
vcvarsall.bat x64 8.1
vcvarsall.bat x64 store 8.1
If you use Qt Creator, you are out of luck. Qt Creator just detects the installed MSVC toolchains, but does not provide any means to add options to the vcvarsall.bat call or to manually add an MSVC toolchain.
Please read the answer of Benjamin T first. This answer elaborates on how it can be configured using QtCreator
QtCreator allows to specify the arguments passed to vcvarsall.bat. Go to Tools > Options > Kits > Compilers:
Clone the desired Auto-detected compiler(s)
Fill in the desired Windows SDK version in the last field of Initialization:
Optional: update the Name to be able to find it back easily in the next step
Under Kits > Kits, change the compiler(s) to your newly created ones (for the desired Kits).