Creating a class library in visual studio code - .net-core

It might be a silly question, Let's say I don't have a Windows OS, have a Linux. I have created a .Net core console app, also want to create a class library and reference it in console app. I can't find if i am able to do it also couldn't find a sample on Microsoft .Net core page.
Is there an extension in vs code? Or isn't it possible with it?
If i am mistaken could you please guide me?

The best way to do it is from the console, since you are using the latest supported templates this way. VSCode also has an integrated terminal you can use for this.
$ dotnet new lib -o MyLib
$ dotnet new sln #assuming there is no .sln file yet. if there is, skip this
$ dotnet sln add MyLib/MyLib.csproj
$ cd MyConsoleApp
$ dotnet add reference ../MyLib/MyLib.csproj
If you need different frameworks, you can use the -f argument:
$ dotnet new lib -o MyLib -f netcoreapp2.0
or manually change the <TargetFramework> element inside the generated .csproj file.

Related

Recompile aspnetcore from official sources

I want to recompile aspnetcore from official sources.
Here is what I've done:
$ git clone https://github.com/dotnet/aspnetcore
$ cd aspnetcore
$ ./restore.sh
$ cd eng
$ ./build.sh
I have a lot of dll's in artifacts subdirectory.
Now, what am I supposed to do with this dlls ?
I have create before a blazer server project, in an empty directory with this command:
$ dotnet new blazorserver
I have try to add a reference to some dlls in previous artifcats subfolder; but the project does not work with my custom compiled version of aspnetcore.
I can see an existing dependency: Microsoft.AspnetCore.App. But I can't remove it.
My question is: how can I create a blazorserver project which work with a custom compiled version of aspnetcore ?
Thanks

Dotnet core issue

I have faced with a problem in my dotnet api project .
I have project.csproj file but still this error while dotnet run command.
Couldn't find a project to run. Ensure the project exists in path.
I build the project via (dotne new project -o Myproject -n Myproject )
Command I don't know what is wrong please help me out of the problem.
you need to add Template and lang
(Template options)
check this here!

Create single framework dependent exe file with .NET Core 3.1 and only include third party dll

is it possible to create a single exe file with only third party libraries included?
I have a small console app with a third party library.
If i use the following code it is still 26 MB.
dotnet publish -c Release -r win10-x64 /p:PublishSingleFile=true /p:PublishTrimmed=true
I have found a solution.
Run the following code in the folder which contains the project file.
dotnet publish -r <rid> --self-contained=false /p:PublishSingleFile=true
You can get the rid (runtime id) from:
https://learn.microsoft.com/en-us/dotnet/core/rid-catalog

Using Qt Installer Framework to create my Application Installer

I want to create an installer for my Application. So, I have read about Qt Installer Framework and I tested the tutorial example and create the installer and everything work find with the example. But I have a doubt when I try to do the same process for my Application. When I compile the code a folder is created at the same level of my code:
MyApplication (my code)
build-MyApplication-Desktop_Qt_5_4_1_MinGW_32bit-Release (code compiled)
So my questions are:
What files of the compilation do I need to copy into the folder myinstaller/packages/vendor/ recommended by Qt Intaller Framework?
If I have dependencies of Qt like serialport, multimedia, and others, how do I insert these dependecies with Qt Installer Framework?
windeployqt.exe is what you want. Just run that on the command line and give it your executable as the argument. It will automatically copy in all the required Qt libraries and even provide the runtime redistributable installer. Then you can use the binarycreator to generate an installer.
You can put all the dependencies in myinstaller/packages/vendor/data, along with your exe. and eventual additional files. I recommended using i.e. dependency walker for finding all the required dependencies. Some of the binarycreator tutorials on qt are outdated; make sure you use the command
<location-of-ifw>\binarycreator.exe -t <location-of-ifw>\installerbase.exe -p <package_directory> -c <config_directory>\<config_file> <installer_name>
with the appropriate arguments.

QT: normal VS project file to build?

I'm using QT (4.7.3) and I'd like to make normal VS solution/project files, build it, and step through the code with debugger to learn the code while reading tutorial...
Instead I have that yet another make qmake which supposed to be able to generate vs solution/project files but it seems that all it generates is some junk empty project files.
Here's what I did (from QT command promt):
cd c:\qt\4.7.3\examples\tutorial
qmake -t vcsubdirs
qmake -t vcapp
qmake -tp vc
but all of them generate random junk or errors...
I assume that I can also generate such solution for entire QT (from c:\qt\4.7.3) to build it from source...
What's the proper way to do it? It has tight integration with VS (designer, add-in etc) it just doesn't make sense that there is no normal solutions/project files there.
Did I do something wrong, or VS is kind of unsupported build platform? :)
Except for a few modes, like -project, qmake expects a valid project file to exist before you run those options. You'll also want to make sure that you're using a QMAKESPEC that corresponds to one of the MSVC versions. This SO post has some good details. To summarize:
Create your project file
Set your QMAKESPEC
Generate the solution file from the project file
That might look something like this:
$ qmake -project
$ set QMAKESPEC=win32-msvc2008
$ qmake -tp vc
qmake -project will regenerate the project file, so don't do that if you have modified your project file at all. The qtnode website also has some good information on using Qt4 with visual studio.

Resources