Posts

Azure YAML Pipelines for NuGet publish for internal use

YAML file from my Company Tech Formats name: $(majorMinorVersion).$(semanticVersion) trigger: - none resources: repositories: - repository: RepoNameHere type: git name: NameItAsYouWish ref: main trigger: branches: include: - main pool: vmImage: ubuntu-latest variables: majorMinorVersion: 1.0.0 # semanticVersion counter is automatically incremented by one in each pipeline execution # second parameter is a seed value, resets when referenced majorMinorVersion is changed semanticVersion: $[counter(variables['majorMinorVersion'], 0)] jobs: - job: PublishToNuGetfeed displayName: Publish to NuGet feed steps: - template: NugetPublish.yml parameters: LibraryProject: ProjectNameToBuild PublishFeed: FeedToPublishTo Copy to Clipboard parameters: - name: LibraryProject displayName: Full Library Project Name type: string - name: PublishFeed displayName: Feed To Publish To type: string...

RSA and JWT in .NET 8

Code below is a helper class to help sign and use public key to verify, both keys values must have the "BEGIN RSA" and "END RSA" lines public class JwtHelper { private readonly IConfiguration _configuration; public JwtHelper(IConfiguration configuration) { _configuration = configuration; } public RsaSecurityKey GetSigningPublicKey() { string keyText = string.Join(Environment.NewLine, _configuration.GetSection("PublicKey").Get ()); var rsa = RSA.Create(); rsa.ImportFromPem(keyText); RsaSecurityKey publicKey = new RsaSecurityKey(rsa); return publicKey; } public SigningCredentials GetSigningCredentials() { string keyText = string.Join(Environment.NewLine, _configuration.GetSection("PrivateKey").Get ()); var rsa = RSA.Create(); rsa.ImportFromPem(keyText); SigningCredentials signingCreds = new SigningCredentials(new RsaSecurityKey(...

Blazor WASM hosted as Azure Static Web App and how to handle direct links

Long time no post! i have been busy trying to "lunch" my PWA app https://www.homeyummies.net , one of the challenges i faced was when i communicate direct links to the users like https://www.homeyummies.net/register that gave the user an Azure 404 page although it's a valid path on the Blazor WASM app, but as this is an SPA and routing is happening at client-side, when calling this directly the server looks for https://www.homeyummies.net/register/index.html and as it doesn't find it, it return 404. a couple of google searches and i did find some solutions out there for that, and when trying to implement them i got a major issue, handling this issue can only be really tested after deployment as part of the solution do relay on what are you hosting the Blazor app on, i did try a couple of them but nothing really worked without issues! but when i combined a couple of them together it did form a good solution for and i though to share it so the solution have 3 part...

Blazor and Square Payments

Another day of poking around and conquer challenges. For my project "HomeYummies.net" i was trying to figure out a solution to process payments using a payment provider but for others, as i wanted the funds to go directly to cooks accounts. after some research i settled on Square as such functionality was addressed more obviously there. But ... how can i get their magical box display on Blazor WASM app i have as a front end? after some decent effort i managed to do so and also have a way to submit and get a token to be used along with a cook OAuth token to process a payment for them! i though to turn this into an open source library, but not quite committed to that yet, but if you land here search for something slimier here you go :) https://github.com/UpwardInfo/BlazorPay/tree/dev

Microsoft.IdentityModel.Tokens version 6.15.0 no user context in AuthorizationHandlerContext

A lesson learned i would like to share. I had a working JWT using RSA key pairs on a .NET 6 based API, installing Microsoft.IdentityModel.Tokens version 6.15.0 (latest) broke it, my custom policy handler were not getting the user context! I tried everything i know to fix it from my side but only restoring back to version 6.14.1 fixed it for me. I checked the package Github and it seems there are a couple issues mentioning dependencies version!

revenera InstallShield and Web.Config authentication mode="None"

Image
 So, i came upon this uncommon scenario. I had a very working InstallShield to deploy a Web API into IIS, after updating to 2020R3 i think, all of the sudden the deployed site was not functioning in the most bizarre way. The API did have a couple of config./admin pages where it was working just fine, API connection to the database source was working fine as well, the connection test did include testing user credentials as well, but when i tried to use same credentials on an endpoint, i would a message that authentication was denied for this request! to add to the mix, i had the same exact Web API on the same exact IIS and the same exact connection running from Visual Studio just fine! so after many many hours of testing and smashing my head against the wall 😫, i found out the root cause, for some reason InstallShield on deployment was removing below line from my web.config included with the Web API app. <authentication mode="None"/> Copy to Clipboard now that was h...

FINALLY remove unused reference is here

 i normally do not check release notes, but something pushed me to do it this time when i was about to upgrade to Visual Studio version 16.10.4, and I FOUND THIS ! Although the screen shot doesn't till what type of reference this would handle, is it only limited to NuGet packages? dose it extend to directly referenced DLLs (yes some folks still do that!) Framework files? Anyway i am existed to try this out and will update this with any findings i feel worth to share, so stay tuned! UPDATE: i am very disappointed, it's marking needed referenced projects and packages as not needed!, like i have it in a using for a class, and it's in bright white because it's used, and i can see it's being used, still it get in as unused reference, while other projects i get a message that there isn't any unused references! hope Microsoft fix this, it's really a neat feature specially for Blazor WASM , where every mb count

Visual Studio, Blazor WASM, and Docker

 So as usual my attempts to create something take to places where i find things do not work the way i wanted, then i find myself searching for a way to get things to work i want them, and in this case it might be the way a lot of people want to. last weekend i wanted to explore how easy or hard to containerize / Dockrize a .NET5 back-end, Blazor WASM front-end app. for the back-end things were super easy, just right click, add docker support, add containers orchestration and all was working, running, and debugging according to plan. Now when i tried to do the same for a Blazor WASM project things got a it ugly, seems like Visual Studio generate these according to project type, and i guess it saw the Blazor WASM as another .NET hosted web app, which is and is not quite! See Blazor WASM are entirely client side running, the server is there to just provide files but no process occur at the server, so technically you can host a Blazor WASM app on any web server (like Nginx) without the...

Simple PayPal page with Vue

So, i needed to create a pay page for my company site www.upwardinfo.com. i choose to go with PayPal buttons on an HTML page, simple and fast. but i needed more, so it thought why shouldn’t i hook PayPal buttons to a simple Vue can’t app, and do some URL parameters that can be intercepted by JS (yes you can so that!). The idea was simple, have an HTML and JS script you can host anywhere, and the page should be able to have two URL parameters for a description /name and amount to be paid, if those values did not exist an input field should be available for user input, and as I have Vue why not do some validations as well. If you want to take a look on the code and use it on your page visit this code repo.

Blazor how to generate that SHA256 check

So ... I see that Balzor + .NET 5 (where did Core go?!!) is now do have what i want to get my things running but of course as always something was missing, see Blazor lazy loading is just the thing i was looking for but it doesn’t work unless i reference the module/razor component library on the main project, which i exactly what is don't want. Fortunately this time everything was kind of there, just a bit trouble to do myself. See if you create a client side Razor app, you get blazor.boot.json file generated and on that file you get lazyAssembly entry which supposed to make browsers only get these assemblies if needed (can't see this working on Firefox or Chrome but that's another story), and if you list your assembly there and follow instructions in here magic happen and the page you created on your razor component library works! But, first you need to be able to calculate that sha256 value for your assembly! Which at first i couldn’t figure out how, but then found this ...

EF Core two data models on two separate projects / dlls with a relationship

Again stuck on my learn / dream project WorkNxt , what i though is a very simple task turn out to be a bit tricky. as i am trying to separate each module and load things at runtime and use DI, i encountered a problem that one of the data models i created under one module need to have EF relationship with another data model on another module, each of course was on a separate project / dll. ideally i didn't want to reference the other module project but to make things even more difficult this was one-to-one relationship and i needed it from both sides and i needed to use it on a ThenInclude as i want to include data from one of the models on the results of the other one. So even if i was ok with cross modules reference which i was trying to avoid i will fall for circular reference trap as you would need to use each class on the other to create the relationship. After many hours of banging my head against the wall, and trying a couple of suggestions from EF core team through the issu...

Tabulator on Bootstrap tab

As i was going on my project WorkNxt , i found a new interesting problem. i mean this one of the main reasons i started this anyway, is to find and solve interesting problems!  i am using Tabulator and Bootstrap along with other JS and CSS libraries on this project, and what i wanted was very simple, to have a bootstrap tab navigator with two tabs each with a Tabulator table on it. Simple?, not really, see what i found out is for some reason Tabulator might have trouble rendering in a Div with css display set to none, which is exactly the not shown yet tab(s) would be. How did i resolve this, and i would dare to say it's a very good solution, is the little JS script below function redrawTable() { tabulatorTable.redraw(); $('#detials-tab a[href="#TargetTab"]').unbind('shown.bs.tab', redrawTable); } $('#detials-tab a[href="#TargetTab"]').on('shown.bs.tab', redrawTable);

How to load a DLL and runtime, invoke a method by name, get result object and use it as a parameter on another unkown DLL .NET Core

That post title took me a while to come up with, but my idea is pretty simple, what id you need sort of a bootstrap that don't reference DLLs, still be able to manage a simple operation of of invoking methods and pass results to the next DLL on the list. C# and .NET Core as a strong type based doesn't really have obvious ways to accomplish this, but i think i got to it with the following code, what do you think? string sourceAsmName = "DllToLoadName"; Assembly sourceAsm = AssemblyLoadContext.Default.LoadFromAssemblyPath(AppContext.BaseDirectory + sourceAsmName + @".dll"); AssemblyLoadHelper.LoadReferencedAssemblies(sourceAsm); Type sourceType = sourceAsm.GetType(sourceAsmName + "." + source); MethodInfo? sourceMethod = sourceType.GetMethod("extract"); object? sourceInstance = Activator.CreateInstance(sourceType, new object[] { _config, _logger }); Task sourceTask = (Task)sourceMethod.Invoke(sourceInstance, null); _logger.LogInformati...

Vue ajax search component

So as i was on my journey learning and creating www.worknxt.com , i needed a Vue component that: when user type it goes and call an end point. replace part of the URL with search text. coming back with results, user can select one but then the value that go up to parent is like and Id value of selected item while keep the display text of the component on another value. everything should be assigned through props so this can be reused. i googled but couldn't find any free Vue component that accomplish this and satisfy my requirements. below code is what i ended up with, let me know what you think, it needs some work on responding to keyboard keys like down arrow but i think it's a good start, so i though to share. Vue.component('vue-autocompleteajax', { props: { placeHolderText: String, minLengthToSearch: { type: Number, default: 1 }, ajaxUrl: String, partToReplace: String, idProperty: String, textProperty: String, ...

how to copy NuGet packages from one project to another

You probably faced that problem at least once, here you are working on your modules trying to build a new model for your solution, create a new dll project and ... here it comes, NuGet packages, you need to have manually install all these NuGet packages that you know form the base of needed libraries for your new module or plug-in, and you need to get every package plus the versions right. If you are like me this would be a soul crushing task to do, so in order for me to be more "efficient" i searched for a way to copy that to the new project, at first i thought well that is easy, just copy "package.json" file, right? , wrong see for some reason this didn't work for me, i was not able to simply do this and restore packages, things went crazy and it seems it's like taking forever! so i have to come up with something even more "efficient" so here you go, hope this save you sometime and but smile on your face just execute below on Visual Studio...

Microsoft TechNet Gallery is going away

Image
so Microsoft is retiring TechNet Gallery where i proudly shared with the public two power shell scripts i have written and where downloaded almost a thousand time through this. so i had to move these somewhere else and re-share them with the world. check them out at https://dev.azure.com/platworx/public-powershell/ , i did a couple of small utilties in my life that i am i am proud of, this is one of them.