Below you will find pages that utilize the taxonomy term “dotnet”
Posts
Inconsistent templates in visual studio and dotnet cli when dotnet_cli_home set to custom location
Due to security policy, I had to set dotnet_cli_home to non-default location to run some building steps. Things went quite well until not. All my command line usages and batch scripts work, until I tried to create a project using the custom project template via Visual Studio and noticed that old deleted template was shown in "Create a new project" dialog.
I tried several options and none of them works for my case.
Posts
Fold and Reduce in LINQ
In functional programming languages, there are several difference betwee them. I was quite interested in functional programming, even I spent some time to learn haskel and scala. I knew what I can use Select for map, not sure about folder and reduce
FeatureFoldReduceInitial ValueRequires an initial value.Does not require an initial value.Function Signature(A, B) => A(A, A) => AApplicabilityCan be used on empty collections.Requires a non-empty collection.VariantsfoldLeft and foldRightreduceLeft and reduceRightStarting PointfoldLeft starts from the left.
Posts
msbuild custom task and runtime reflection
Most information about custom task of msbuild are quite basic, it will get complicated when it is involved reflection. I tried several ways according searching results and answers from chatgpt: reflection, assemblyLoadContext and mono cecil. The most promising one is mono.cecil.
I tried directly loading assemblies and via AssemblyLoadContext. They all failed to load some microsoft assemblies. It looks awkward even I can change my build scripts to copy those assemblies.
Posts
.Net sdk version vs runtime version
What will you do when you encountered a runtime version is disallowed for specific version say 8.0.6 in building environment? Install the specific runtime version, right? Please hold, I show you my story.
I initially thought I couldn’t run the below commands to install it, it is not. After several attempts, My colleague spotted the difference between runtime version and sdk version. They are different. A runtime version is supported by several sdk versions.
Posts
setup nuget local packages feed
Nuget local feed Prerequisites nuget.exe is installed in C:\packages and in the command search path.
Setup local feed Assume C:\packages\.nuget-local\packages will be the locations to install local packages. and several local dev packages need to install.
Packages below: - "C:\packages\test.4.1.0-beta-24159.1.nupkg" - "C:\packages\testa.4.1.0-beta-24159.1.nupkg" - "C:\packages\testb.S3.4.1.0-beta-24159.1.nupkg"
Run below commands to install above packages into source C:\packages\.nuget-local\packages
REM run command line with C:\packages as working directory nuget.exe add tes.
Posts
Recent learnings in dotnet and FHIR
In the past several months, I called it quite intensive. I need to master the knowledge of FHIR, advanced dotnet technologies (attributes, generator, reflection, code emit, expression tree, advanced linq, customized aspnet pipeline, nuget package), code optimization technologies and several aws technologies (DynamoDB, S3, glue, spark) in depth to meet the schedule of a project. You really can’t account on solution architects or support engineers from cloud providers. I don’t get one perfect answers from them so far when I used their services.
Posts
Issues and corresponding solutions of dotnet razor
Seperate view dll issues Put views (cshtml) into the main web project
'RazorTargetAssemblyInfo.cs' could not be found GenerateAssemblyVersionAttribute is set to true : af file MyProject.RazorTargetAssemblyInfo.cs is generated
<Project Sdk="Microsoft.NET.Sdk.Razor"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> <GenerateAssemblyVersionAttribute>true</GenerateAssemblyVersionAttribute> </PropertyGroup> https://github.com/dotnet/aspnetcore/issues/37795#issue-1034241118
The namespace 'Razor' already contains a definition for 'Template' https://stackoverflow.com/a/58140724/1101691
Duplicate 'Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute' attribute How to decompile/extract(cshtml--(razor view)) from dll https://stackoverflow.com/a/69951824/1101691
Posts
decompling dotnet assemblies
I used dotpeek for a while to decompile dotnet assembly. Only yesterday I finally found a way to export project from dotnet assembly. The picture below is the menu to do that in dotpeek. However the version I used doesn’t perfectly decompile lambda expression. The decompiled code of lambda expressions are very hard to understand.
Ilspy is one of decompiler that can decompile lambda in a understandble way.
Posts
Scaffold Identity into an MVC project without existing authorization
Today I tried to integrate identity into mvc projects. The main doc about this is at https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-7.0&tabs=netcore-cli#scaffold-identity-into-an-mvc-project-without-existing-authorization
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design dotnet add package Microsoft.EntityFrameworkCore.Design dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore dotnet add package Microsoft.AspNetCore.Identity.UI dotnet add package Microsoft.EntityFrameworkCore.Tools # add second dbcontext for identity and authorinization, use database sqlite dotnet aspnet-codegenerator identity -dc MyApplication.Data.ApplicationDbContext \ --files "Account.Register;Account.Login" --databaseProvider sqlite dotnet ef migrations add CreateIdentitySchema \ --context MyApplication.Data.ApplicationDbContext dotnet ef database update \ --context MyApplication.
Posts
Set timezone in asp.net 6.0 in linux container
According to many articles one the web, the way to set timezone is as following:
cp /usr/share/zoneinfo/Asia/Singapore /etc/localtime echo 'Asia/Singapore' > /etc/timezone You can indeed get the correct time if you run it in dotnet core 5 docker linux containers. However you couldn’t get the correct local time in dotnet 6.0. I found the issue About time incorrect of docker image about aspnet-6 #62545. After I tried serveral combinations mentioned in the issue, finally I got a working solution.