Alexicon
Strange seemingly new behavior of docker-compose with dot net C# solution
I have a solution with multiple C# projects in it. I have a docker-compose.yml which up until today worked. Now however, when I attempt to build this solution in Azure DevOps with docker it is giving me the error
Surly I do not need to rename all of my actual C# projects to be all lowercase and remove the periods? That seems ridiculous considering I believe it is C# convention to have projects be capitalized. Additionally, this worked just the other day, I must have made a change somewhere or something for this to happen.
I have already attempted to use
In the docker-compose.yml but it seems to have no effect.
Any insight would be appreciated since google is giving me nothing.
Here is what my docker-compose.yml looks like:
13 replies
❔ Git Hub Actions Dot Net Push keeps trying to use 1.0.0.nupkg but that file should not exist
I have an established GitHub workflow I have been using for a while that builds, tests and pushes NuGet packages for a large C# library solution.
This workflow has been working for ages doing exactly what I want which is to package all the projects into NuGet packages for me, where the version of those packages is 7.0.[run number].
However I just recently added a new C# class library project to the solution, and I am getting a frustrating issue with this workflow. Now even though the new project is set up identically to all the others it keeps trying to push a myproject.1.0.0.nupkg file instead of one with the 7.0.[run number].
Whats odd is that this file should not even exist since as you saw in the workflow, I specify that the version prefix should end with the GitHub run number and start with 7.0.
[continued below]
47 replies
❔ Docker dotnet msbuild fails when using source generator reference
I have a solution with two projects. An aspnet api 'MyApiProject' and a regular class library 'MyLibraryProject'. The library project references a source generator NuGet package 'MyGenerator' I created in a separate solution.
When I build and run the solution in visual studio everything works fine but when I build it through docker it is failing because the class file that is generated "could not be found".
Relevant extract from the docker output:
Relevant parts of my docker file looks like this:
All of this makes me think that its not running the source code generator during the build.
7 replies
✅ Simple way to push a C# project as a NuGet package within a GitHub workflow yml
I am not sure if there is a better place to ask this question as its really only C# adjacent, but maybe someone here knows the answer.
Does anyone have a simple and up to date example of how to push a C# project as a NuGet package for GitHub actions? There are a lot of examples online but all of the ones I can find seem to be out of date or use a third-party workflow which I would like to avoid.
If I was using Azure DevOps I would simply add the following to my yml file:
however, the GitHub actions equivalent seems to elude me.
21 replies
❔ Is there a better way to insert a configuration source before the appsettings files?
I have an AspNetCore web API where I am using the appsettings.json and appsettings.Development.json, which are automatically added to the configuration manager when you call however I am also adding a azure key vault as another configuration source like this:
The issue is that the key vault and appsettings.Development both contain the same connection string key but with different values. Because the appsettings are added before the azure key vault, the key vault connection string is always used, however I want to use the connection string from the appsettings.Development when its available.
So the obvious solution is to do the following:
And this works but I was wondering if there is a more elegant or correct way that I could simply insert the azure key vault before the appsettings configuration.
I suspect there isnt anything better based on what I can find but I figured I would ask just in case.
3 replies
Newtonsoft JsonConverter to replicate the serialization of the JsonObjectAttribute on an IEnumerable
Can someone help me create a Newtonsoft.Json.JsonConverter that will write an IEnumerable the same way one is written if the class has the JsonObjectAttribute?
For example, given this class:
I need the result from this:
To look like this:
Doing the above works fine if the class has the JsonObjectAttribute on it like this:
However without the JsonOjectAttribute the result will look like this:
But I cannot use the attribute since I do not own the class I am trying to serialize in this way, Thus I need to write a converter to do this same thing but I am struggling to figure out how.
I tried googling this but I could not find any similar examples and everyone just seems to suggest using the JsonObject attribute, which I can't and do not want to use.
Any assistance would be appreciated.
3 replies
Using the new INumber interface to determine if an object is a number without having the generic arg
With .net7 we now have the INumber<TSelf> interface which is pretty cool, and I thought I found a place where I might be able to use it for the first time. However, I am running into some trouble.
I am wondering if there is any way to know if some ‘object’ is a number and return the ‘One’ abstract static property from the INumber<TSelf> interface it would implement. The issue is I do not have a generic argument to plug in for TSelf, and I cannot add one in this case since the method I am working on is an override of a method outside of my control and it does not have a T generic argument.
Here is a cut-down example as a x-unit test of what I am doing and what I have tried.
Unfortunately, with INumber<TSelf> being so new there is not a lot of information about it online so before I give up, I figured I would see if anyone here knows how to achieve this.
7 replies