Turn2Jesus2
How do I get webpack to integrate with cshtml files?
I have an ASP.NET Framework 4.8 MVC project that has cshtml files.
I currently do bundling via BundleConfig.js. I need to migrate to something else because we are migrating to ASP.NET [Core] and that functionality doesn't exist there.
Microsoft recommends switching to something like WebPack.
I am switching to webpack now before migrating to .NET so that the amount of churn necessary for the .NET upgrade is minimized. However, I'm finding it hard to see examples of how this integrates with .cshtml files.
Currently, my bundles are generated with a hash to break the cache when we deploy.
I am expecting something similar with webpack. However, my generated bundles don't have hashes (and they probably don't need them). But how do I get my cshtml files to reference a hashed version of the assets so that when I deploy updates to the website, users download the new bundles?
My current option is to just have webpack generate the assets and statically link to those assets from within the cshtml file, but when I push updates, clients will download the old versions which would be incompatible with the new version.
I'm not sure why I'm having so much trouble. I figured that if Microsoft recommends it that there'd be examples of how to migrate to it.
Thank you for any help!
10 replies
How should I include 3rd-party JavaScript Libraries in my ASP.NET Framework SDK-style project?
So I SDKified this ASP.NET Framework 4.8 website.
I see that we have lots of nuget packages for 3rd-party libraries like infuser, trafficcop, etc.
I also see that we've committed these javascript files wherever we felt like it and referenced everything to those paths.
I also see that there appears to be a SO article that says not to use nuget for javascript files, even though you technically can.
I recognize that we have a bit of a mess. What is the correct way of including 3rd-party JavaScript libraries?
It seems super suspicious that TrafficCop has only one version available, which lends credebility that nugety may not be my best choice for including these libraries.
Psst: I'm about to start migrating this crap over to .NET, but I'm trying to get as much of this project up-to-date to minimize the changes necessary to get it to work in .NET.
36 replies
How to get .NET framework 4.8.1 installed on IIS Web Server running Windows Server 2019 via choco?
I've upgraded my .NET Framework website to .NET Framework 4.8.1. In my choco package which installs the website, I've switched the dependency to
choco install netfx-4.8.1 --version 4.8.1.20250219
However, it always fails the installation.
It doesn't give me much to go on.
What do you recommend?
I've even ran the windows updates manually and it installed. I am hoping for an automated way vs. just installing the .NET Framework Runtime manually.
30 replies
Why is `dotnet publish` not including Roslyn for my ASP.NET Framework 4.8.1 Web App?
I converted my .NET Framework 4.8.1 Web Application to SDK-style projects (like Microsoft recommended).
I think I've worked out all of the quirks except for the publish piece.
For some reason, the publish likes to modify my web.config and add stuff to it not included in the original.
It also is not including the roslyn folder in the bin folder in the published output.
ANYWAY. I worked around the web.config getting molested. Now I just (I think) need to find a way to include the
bin\roslyn
folder in the published output.
I've tried uninstalling and reinstalling Microsoft.CodeDom.Providers.DotNetCompilerPlatform
. Reinstalling it did change the web.config section just a tad from what it was, but it works while debugging in Visual Studio.
I've also tried just uninstalling that nuget package, but the website fails to run with it removed.
Thanks for your advice.27 replies
✅ How to copy an EXE from a NuGet package in SDK-style project with PackageReference?
In the old msbuild format, I was including a nuget package that distributed an EXE file among other things. In the Content include, we referenced back to the exe using relative pathing ..\packages\my.exe and used Link to place it in the build output. How do I do that in PackageReference world?
This is my old msbuild-style project content include where it worked
It copied the EXE file to the bin directory, where I want it
packages.config
However, now, it's in SDK-style format and I can't figure out how to include it.
How should I solve this?
2 replies
Immutable Service Options
I have a service which mutates its options. I discovered that IOptions<T> creates a singleton and all of the unit tests I'm running all get the same options but unrelated services are mutating the options and other services are seeing those changes.
I'd like to have a simple solution that would ensure the options are not mutated and should something try to, it breaks or doesn't compile or whatever.
If there's a simple solution, what is it?
Someone in the chat yesterday mentioned something about IImmutable, but I don't know the specifics.
I saw something about an ImmutableDictionary, but I'd like the whole class to be.
Ideas?
I kind of think this should be a standard of some sort.
14 replies