I have 2 projects, an ASP MVC project and an ASP Web API project using .NET Framework 4.7.2
From a coding perspective both of these project types are very similar.
Yet the MVC project publishes to <100MB and the API project to 500MB+, despite the MVC project containing numerous JS libraries and other content.
This seems to be down to a folder the Web API project includes called "runtimes". Is this folder necessary, can it be optionalised, are there some optimisation options I can set?
This is the framework which is published because of the settings in your publish profile.
Publishing your app as self-contained produces an application that includes the .NET runtime and libraries, and your application and its dependencies. Users of the application can run it on a machine that doesn't have the .NET runtime installed.
Publishing your app as framework-dependent produces an application that includes only your application itself and its dependencies. Users of the application have to separately install the .NET runtime.
https://learn.microsoft.com/en-us/dotnet/core/deploying/
Related
I'm developing a C#.Net application that uses the .Net Framework but I'm having trouble when users are installing the application on their computers. Some of them just don't know how to install the .Net Framework.
I'm searching for a solution to this problem and I found the self contained deployment use in .Net Core applications.
The problem is that my application doesn't use .Net Core, it is a WPF application.
I already search the web and all solutions I find brings me to the .Net Core self contained deployment.
What can be done in order to deploy a "self contained" .Net Framework application?
Thanks in advance.
You can use WiX to create a "bootstrap" installer, which will install required frameworks before installing your application.
http://wixtoolset.org/documentation/manual/v3/howtos/redistributables_and_install_checks/install_dotnet.html
Find a version of the .NET Framework that all of your target computers already have, and set Visual Studio to target that version of the framework.
Then, just copy/paste all of the files out of the bin/release folder into a folder on the target computer and run your program's executable.
If all of your target computers have Windows 10, you can deploy using version 4.6 of the framework, and be guaranteed that your clients already have it.
I run a local IIS Server with a DotNot Core 2.1 application deployed to it. I like to keep up to date with the latest security patches that are released monthly and I use the Core download page to do so.
My question is, what ALL do I need to install each time and in what order. I usually find a Framework installer and I chose the SDK just to make I have everything. Then I find a ASPNET.CORE installer and I run those in. Finally, I run the Web Hosting Bundle.
Am I doing too much? Do some of these items copy over the same assets? What is the correct proceedure?
If you need to host an asp.net core web app, follow the Host ASP.NET Core on Windows with IIS Guide.
In terms of installing things, follow the Install the .NET Core Hosting Bundle Section
The bundle will install 3 things:
.NET Core Runtime
.NET Core Library
ASP.NET Core Module (for IIS)
I've built an webapi using .net core 2.0v on my windows system and trying to deploy it on the AWS linux ec2 (Centos v.). To deploy it on the linux machine i've used nginx server as tomcat doesn't support hosting of .net core 2.0 till date (which I read on blogs). Error I am getting which is below
"An assembly specified in the application dependencies manifest (WebApplication1.deps.json) was not found: package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.1.1' path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll' This assembly was expected to be in the local runtime store as the application was published using the following target manifest files"
I know it's a simple dll issue by reading but what I've tried so far and observed is following
In step 1 when I tried to install .net core 2.0 sdk as per MSN blog it isn't allowing me to do so and giving error for few dependencies that it's break (so might be the root cause is that.)
In Step 2 I've checked the opt/dotnet/ dir, In this I am only finding 1.0.0-preview2-1-003177 folder. I am expecting dot net core 2.0 folder should also be there. as i've installed it with a shell script given by MSN. (might be full installation of packages is not yet happened)
In Step 3 I've tried to create a new WebApi Project from Aws terminal by the help of dotnet new -t command. but it's giving option for creating only web project. so I created one and in outcome I got a MVC Web Application rather then a WebApi also which was based on dot net 1.0 structure.
The same if I try on windows VisualStudio command prompt then it's giving me the option of creating WebApi project on terminal.
In Step 4 I've copied my project itself there on ec2 and tried to build it with the help of dotnet command but it's denying for any projects are available on the dir. (might be it's not recognizing the 2.0 application.)
In Step 5 I've tried to publish it with Self contained deployment feature of .net core, and I am finding this option might be helpful in such a scenario but again I am getting below error. In previous version of dot net we tend to solve these errors by writing specific version in web.config files but in .net 2.0 I don't know how to solve specially in self contained deployment.
Could not load file or assembly 'System.Runtime.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference.
After doing all these should I treat like .net core 2 or 1 doesn't support webapi on linux environment till date or is there some workaround to do so. I've googled a bit but everyone is suggesting to depoly web application (1.0v & MVC application). Or Is there anything I am missing to do on AWS ec2 Linux side.
Note: Above WebApi I've published on IIS and it's working fine. same dll I've copied into linux and tried with.
In Conclusion I am just trying to deploy an WebService(.Net core 2.0) on AWS ec2 (linux, centos env.) so if anyone of you have done the same let me know above is the my analysis(Which may be wrong)and as per my understanding which is not that much on both of the platform(AWS, .Net core 2).
After trying Step 5, I am foreseeing that there might be some possibility.
I am developing a Azure Web Site with asp.net core, but I have a problem with dll version.
I am using some compoment developing internally, but two use other compoment with distinct version. I know that GAC, <probing> can solve the problem but the enviroment is Azure.
With asp.net core can reference distint library by .net framework
Can I reference by framework two dll with distinct version ?
Expanded the question
I have two third-party libraries, don't have the code. One library use Newtonsoft.Json with version 8.x and the other library uses 7.x
When the asp.net mvc application is builded there is conflict with the Newtonsoft.Json version copied to bin folder
We developped 2 differents applications with visual studio 2013 :
The first for the front-end in C# .net mvc5
The second for a web service in C# .net WebApi 2
Both applications use newtonsoft.json nuget but with different versions (6.0.8 for front and 8.0.2 for web api).
We use Local IIS to test and debug.
In IIS we create 2 websites, and 2 separate application pool.
If i compile the the web service after front end, everything is fine.
If i compile the front end after the web service, the web service crash with the 6.0.8 version of newtonsoft.json ! Why ?
The application pools shared some dlls ?
I found some articles with the "Specific version" option of the reference in the projects. With the "specific version" at true, both version can run in parallel. But i don't want to do that.
I can also update the nuget to have the same version in both projects but it is a workaround, the problem could still there with another dlls.
I need to understand why with 2 applications pool share dlls (with différents versions)...
So do you have an idea :-) ?
Thanks
Whiletrue
Following from your comment - the reason is quite simple now. your webapi and mvc project both depend on classlib which depends on newtonsoft specific version. so when you build any of webapi or mvc project, classlib's dependencies are also added to webapi or mvc project. you can either break the dependency somehow or specify versions in the web config + project file explicitly and have both versions in your Bin folder.