Can I use dotnet publish command to build .NET Framework applications? - c#

I'm in the process of moving to .NET Core. In the mean time, I have two sets of apps - some using .NET Core 3.1 and the rest the full .NET Framework 4.6.2.
Also, I'm trying to make a build script to build all apps with one command.
But dotnet publish does not work for full .NET Framework projects.
How can I use dotnet publish command to build full .NET Framework applications?

dontnet commands only works for .NET Core projects, so It is working as intended!

Related

.NET Core 2 build is not working in .NET Core 3.1

All,
I have a build server that has .NET Core 2.2.110 installed in it. For my new application, I need .NET Core 3.1. So I've installed .NET Core 3.1 in addition to .NET Core 2.2.110.
When I hit dotnet --version I get 3.1
The build is working fine when building applications developed in .NET Core 3.1 but it's failing for the below framework applications and giving me the following error
The imported project "C:\Program Files\dotnet\sdk\3.1.100\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found
I have both 2.1 as well as 3.1 on my build machine, technically applications developed by 3.1 should use .NET Core 3.1 f/w, and apps developed by 2.2.110 should use .NET Core 2.2.110.
Also, any upgraded framework should also support previous versioned apps but in my case, it's failing.
Please help me
Maybe you can specify the target platform in each project.
Add the line :
<PropertyGroup><TargetFramework>netcoreapp3.1</TargetFramework>/PropertyGroup> in you .csproj file to compile with .Net 3.1 or netcoreapp2.0 for .Net 2

If I have mono and .NET Core installed on linux which one will run my code?

I'd installed monodevelop on my linux and build an application with it. It run, but is very slow compared to a windows run, both in release mode. If I install .NET Core and run this app, will it be runing with mono or .Net Core?
EDIT:
Sorry I didn't told you details but now I understand why it run very slow. The library was created with .Net Standard so it can be used by .NET Framework and .NET Core applications, but the application I made and use the library is a .NET Framework Windows Forms. So basically it run as any .NET Famework code and doesn't benefit from .NET Core optimizations.
But the question remains. If I got two of them instaled (.NET Core and Mono) and I ran a .NET Core application, which one will run the application .NET Core or Mono.

dotnet-counters ps doesn't show any processes

I have .NET Core 2.2 application and wanted to use dotnet-counters to get some data about GC. Unfortunately dotnet-counters doesn't see my app (.NET core process) for some reason. When I run
dotnet-counters ps
It returns nothing (my .NET core application is running of course). I use .NET Core version 2.2.8 and dotnet-counters version 3.1.57502. I tried both standalone and Framework dependend version of application.
The diagnostic tools (dotnet counters, dotnet trace, dotnet dump) rely on new features of the runtime exposing the necessary interfaces. These are only present on .NET Core 3.0 or higher.
This means that a .NET Core 2.2 application cannot be monitored / diagnosed with these tools. You will need to update your application to .NET Core 3.0+

Sharing code between WPF & DNX Webapp

I have a WPF application under the .Net framework 4.5 and a web app under the DNX Core.
I want to share some code between those two apps.
I tried to create a "portable classe library" ... with no result.
I tried to do it with a nuget package ... with no result (and too complex to dispatch modifications)
Thanks for your propositions
Normally when creating a portable class Library, you can be compatible with .NET 4.5 and Dnx project. The only problem is that .Net 4.5 relies on csproj when your Dnx project relies on project.json.
Thus you won't have it out of the box, check out your options here: What are my options for sharing code between DNX / ASP.NET 5 projects (project.json / xproj) and other C# projects (csproj) within a single solution?
Note that this solution will probably not work in the next version of dotnet core if they finally remove the project.json...

Difference DNX and .NET Core

I couldn't find any answer online so I try it here: What is the difference between the DNX (.NET Execution Environment) and the .NET Core?
I know that the DNX is the SDK and also used to execute code and the .NET Core contains the CoreFX (Libraries) and the CoreCLR (the common language runtime).
But I still don't get what it is precisely about between DNX and the .NET Core.
My understanding is that .NET Core is the core Common Language Runtime and various .NET libraries used in .NET applications. This would be things like Microsoft.AspNet.Server.Kestrel, Microsoft.AspNet.Mvc, Microsoft.AspNet.Tooling.Razor, etc.).
DNX is the .NET executioner, which is responsible for running your .NET application. Basically, you would install one or more DNX (clr, coreclr, mono) versions. Then you would build your application and type something like dnx run or dnx web from the command-line to run your application.
There is also DNVM (the .NET version manager), which is the tool used to maintain (install, upgrade, uninstall, etc.) versions of DNX. You would do this by entering commands like dnvm upgrade, dnvm install <dnx_version>, dnvm uninstall <dnx_version>, dnvm use <dnx_version>, etc.
And then there is DNU (the .NET Utilities manager), which manages the dependencies your application relies on located in your project.json file every time you add/remove new dependencies in your project.json file, dnu restore would need to be run in order to update the dependencies your application relies before running dnx run or dnx web.
I've heard that dnx, dnvm, dnu will all be under dotnet soon as .NET 5 is now being called .NET Core 1.0

Categories

Resources