I plan to publish my ASP.NET 4.5 application on Amazon Elastic Beanstalk. I have a library ImageMagick.NET that dependent on the Visual C++ Redistributable Packages.
I can't manually install the packages because I deploy the app from within Visual Studio and the servers will auto-scale based on the code that I have.
I want to install the Visual C++ Redistributable for both x86 and x64 so my app can work as intendent.
Right now I get the error:
ould not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies. The specified module could not be found.
That's because I didn't have the packages installed on the server (asked this question earlier).
So from my understanding, I need a way for the packages to be pre-installed, probably either supplying dll's to the bin folder with the merge modules, or initialize an installer from within the project that will launch the package installer after the project is deployed on Elastic Beanstalk.
I need a way to have those packages installed automatically so the ImageMagick.NET dll can work. Thanks.
update: their might be a way to do it with configuration files.
The right way is to use Elastic Beanstalk Configuration files.
These are YAML files, where you can add commands (in the specified format) and upload along with your application package. You could do things like creating files, installing libraries etc. Most of the command line (headless) doable stuff could be handled here.
Customizing the Software on EC2 Instances Running Windows - AWS Elastic Beanstalk : http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-windows-ec2.html
Each time you deploy a new version or re-start the servers, these scripts execute and you can achieve pretty much any customisation.
Related
I have a .net framework project with framework as 4.8. Recently I integrated docuSign 5.12 using a class library and nuget packages. Everything worked fine in development. When I published the exe in server, I am getting could not load file or assembly error. I cleared the references, reinstalled docusign, changed copy to output property to true for all and published again. But same result.
What I noticed is, when installing .net framework in server, it didn’t create a folder called .Netframework in ‘c:\Program Files(x86)\Reference Assemblies\Microsoft’. As the required dependencies missing are system dependencies, they are not copied to published folder.
So, I have another server where .net 4.8 SDK is present and everything worked fine there. My questions are
Why didn’t installation in server didn’t create assemblies?
Do we need to install .net 4.8 SDK for this to work?
How to publish dependencies for these kind of Nuget packages?
I have not added code samples as it is working already. Dependencies are https://www.nuget.org/packages/DocuSign.eSign.dll/5.12.0#dependencies-body-tab.
You can use the publish functionality of VS. It will package your app, including all NuGet dlls and their dependencies and send it to server. If you use Azure - it's integrated into the process. You can even include it in a CI/CD process. But your specific problem can be addressed by just having VS publish the app to your server instead of you manually copying files over there.
As per the comment from Ralf, I checked the references. Found an interesting thing. I already had a binding redirect in the project but, it was added to the class library config file but not the startup project config file. Because of that, my API was referring to old Newtonsoft version. I copied redirect from class library config to my main project config and it started working.
I have C# application (.NET Framework 4.6.2) with WebApi projects which references System.Runtime.InteropServices.RuntimeInformation (v4.3.0) library through nuget package. See
Nuget package reference screen Package was auto-installed as a dependency of 'Microsoft.CodeAnalysis.Razor.2.2.0, Microsoft.DotNet.PlatformAbstractions.2.1.0'
This application was working fine (Builds from my localhost are ok) until I tried to do automatic builds from my teamcity server (different machine). For some reason builds of my app which are provided by teamcity will not start. I get error Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0...'
So I started to investigate and I found out this:
Builds from my localhost (bin/debug) contains lib System.Runtime.InteropServices.RuntimeInformation.dll (File version=4.6.26011.1, Date modified=10.8.2021) --this build works fine
Teamcity build contains lib System.Runtime.InteropServices.RuntimeInformation.dll (File version=4.6.24705.1, Date modified=11.5.2016) --this build is not working
Nuget package which was downloaded (..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0) on both machines (localhost and teamcity server) contains System.Runtime.InteropServices.RuntimeInformation.dll (File version=4.6.24705.1, Date modified=11.5.2016)
And now I am stuck and literally dont know how to investigate it further. Questions I am asking myself:
How is it possible that my localhost builds contains this reference lib with file version 4.6.26011.1 when in my \packages\ folder this .dll contains file version 4.6.24705.1? Does msbuild maybe take this reference from different location? But from where? I swear I searched my computer and I did not found this library in version 4.6.26011.1 (which is apparently copied to bin/debug by msbuild).
Is there a way to monitor msbuild process and see from where it copies this .dll reference to my bin/debug/ folder on my localhost machine?
How to fix my references so the app runs fine?
21.6.2022 Edit:
Thanks to #mu88 comment I have managed to find out that this library is copied from this location: "C:\Program Files\JetBrains\JetBrains Rider 2021.2.2\tools\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net462\lib\System.Runtime.InteropServices.RuntimeInformation.dll" to my bin\debug. I have zero ideas why msbuild is using this path for this lib. (This is only library which is copied from this path)
--Additional info: I am using some AspNetCore references (e.g Kestrel, ..) so I am targeting .Net Standard 2.0. Could this relate? I am asking because my investigation lead to this issue: ms-build-extensions-file-corrupt-my-bin-web-api-folder. In this issue I have found other links to people having similiar problems like this. I just dont understand the solution there :(
So I managed to solve my problem. I had to install .NET SDK to Visual Studio Build Tools 2019 via Visual Studio Installer. Which done "some" magic and it created *MSBuild\Microsoft\Microsoft.NET.Build.Extensions* folder to my msbuild and now during the build process some System libraries are "overidden" and copied from this new location.
So even if I use nuget to download System lib then this package is not used during the build.
I did not manage to find any more info about the build process :( It would be nice if someone could explain this to me. I created a separate question for this here: What is Microsoft.NET.Build.Extensions and how does it work?.
So, I want to create an installer for my .NET Core 3 based C# project. I installed the Installer Projects extension for Visual Studio 2019 and created a new Installer project within my solution. After some trying around with different settings, I ended up with adding PublishItemsOutputGroup for my two executables to the Application Folder.
This (throwing various warnings for duplicate dlls) creates a nice installer package with "supposedly" all required dlls (there are quite a lot of .net libs). However, upon executing one of the installed exe files on a target computer, I am getting:
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '3.0.0' was not found.
- Check application dependencies and target a framework version installed at:
C:\Program Files\dotnet
- Installing .NET Core prerequisites might help resolve this problem:
https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
- The .NET Core framework and SDK can be installed from:
https://aka.ms/dotnet-download
- The following versions are installed:
2.2.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
I know, I could create a gigantic self-contained .exe when publishing the .exe files, however, that seems kind of wasteful to me - creating two gigantic .exe files that contain mostly the same .dlls anyways.
Is there no way to include a .NET Core 3 setup in the installer project as well? I can't find anything on that topic on the internet...
I found this as had same problem, but eventually worked out if you set the publishProfilePath setting in the Installer Project it will include all the files and works fine.
For me replacing PrimaryOutput with PublishItemsOutputGroup works fine, when it comes to gathering the dependencies.
Unfortunately it does not allow referencing those outputs inside the installer. E.g. if you want to run custom actions or create Shortcuts during the installation, it does not work. The outputs are not available.
is there any way to install MSBuild 15 on my machine locally without admin rights?
Microsoft's instsaller on https://www.visualstudio.com/downloads/ seems to inevitably ask for admin rights. I've tried looking into the .exe directly with 7zip, but don't think there's much I could manually extract either (looks like the exe is just a web downloader).
Would there by any other way anyone can think of?
--
Why do I need this? I'm developing on a non-admin machine. I could install the NetCore SDK and VSCode withou admin rights, which is great.
For one of my C# projects I'll need MSBuild to compile though (as I'm trying to use WPF/XAML), specifically MSBuild 15 due to the format of my .csproj files.
In case anyone else is trying the same, I managed to do it;
started with Nuget package Microsoft.Build.Runtime, extracted its contents + downloaded all dependent packages into the same folder, plus a few more (several Nuget Build related ones, also available on Nuget).
Had to fiddle a bit with dependencies, environment variables (so my non-admin install of the Net Core SDK would be found) + including build tasks manually etc., but works now. In the end, I was able to use VSCode to compile a WPF application targeting .Net 4.6.1 that references a few other NetStandard 2.0 projects.
We are currently developing functionality that makes use of the Microsoft.ACE.OLEDB.12.0 driver server-side to interface with MS-Excel files. While I know that the Microsoft Access Database Engine Redistributable is available, I believe that the security managers of the deployment environment will freak out a little bit about running a full setup.exe just for one app (of many) on the shared environment.
So, can we just bundle and reference these DLLs as a part of our build or are we stuck with a full blown deployment using the Microsoft .exe?
Unless stated explicitly anywhere, the DLLs are not redistributable other than via the redistributable package to which you link.
Standard practise from Microsoft is to force you to use the redistributable package, presumably in an effort to avoid lots of bad user experience from botched manual installations. So I think you will just have to accept the deployment of this package.