Posts

Showing posts from May, 2024

Azure Environment Variables

Azure Environment Variables  (such as DB Connection string) .NET 6.0+ can read from the Azure environment variables. Especially useful for database connection strings for Azure databases for development vs. testing vs. staging vs. production, rather than hard-coding them. Old way:     var connectionString = _configuration.GetConnectionString("ApiConnectionAzure"); and in appsettings.Development.json "ConnectionStrings": {     "ApiConnectionAzure": "some DB-Connection-String-Dev-Encrypted#"   } New way: In your Azure portal ( https://portal.azure.com/  ), click on your server. Then click "Settings" > " Environment Variables" > "Connection Strings" tab > look at list of your created environment variables. Add if missing.  Remember the name. In your code the ContextFactory should be,  public APIContext CreateConnectionAzure() {     // NOTE - "MyEnvironmentVariableName" is defined on https://portal.a...

Azure Pipeline YAML for API that requires MSI

 variables: - name: buildConfiguration   value: 'Release' - name: buildPlatform   value: 'Any CPU' - name: major   value: 2 - name: minor   value: 0 - name: patch   value: $[counter(format('{0}.{1}',variables['Major'],variables['Minor']), 0)] - name: sonarQubeKeyRoot   value: $[format('{0}_StorePricing',replace(variables['System.TeamProject'], ' ', '_'))] name: $(Major).$(Minor).$(Patch) trigger:   branches:     include:     - main pool:   name: Azure Pipelines   vmImage: 'windows-2022'   demands:   - msbuild   - visualstudio jobs: - job: analyzeAndTest   displayName: 'Analyze and Test'      steps:            - task: DotNetCoreCLI@2     displayName: 'API dotnet restore'     inputs:       command: 'restore'       projects: |         **/XXXXX.sln       feedsToUse: 'select'...

Upgrading to .NET8 from desktop versions 4.8.X

Image
Upgrade to Latest .NET OVERALL     Problems and differences encountered taking applications from .NET 4.8 desktop to .NET 8 . SUGGESTION    Rebuild the solution and project files from scratch with latest .NET 8. PROBLEMS APIs    On later .NET APIs (post 4.8 desktop), you need to be extra carefully about how the inbound objects are declared.  So if integer in Postman, then must be integer in object.  In older .NET, they accept properties as strings.       Example - Say body in Postman is:          {     "SettingData" : 31000 }    Pretend endpoint method is: [HttpPut("cache/resettimer")] [Produces("application/json")] [ProducesResponseType(typeof(ResetCacheResponse), Status200OK)] public async Task<HttpResponseMessage> MyMethod ([FromBody] InputData input)    Later .NET must be: public class InputData { public int SettingData { get; set; } } ...

MSI Testing

1) Orca allows for viewing inside MSIs, especially the versions of the File contents.  Use Orca from the Windows SDK that requires weird extra installation.       a) download latest Windows SDK and install it       b) search for Orca-x86_en-us.msi under C:\Program Files (x86) and run it       c) create shortcuts and taskbar shortcut to C:\Program Files (x86)\Orca\Orca.exe 2) Verify local box has IIS Express for local testing. Verify IIS Express installed by getting to the command line:   a) >Powershell   b) >get-service w3svc   c) if no service, then:       d)  Dism /Online /Enable-Feature /FeatureName:IIS-DefaultDocument /All e) Dism /Online /Enable-Feature /FeatureName:IIS-ASPNET45 /All   3) Helpful Batch files : Obviously adjust pathing.  MsiWaxOn.bat xcopy "C:\QTDev\StoreAPIs\QT.StorePricing.API\QT.StorePricing.API.Setup\obj\x64\Debug\QT.API.StorePricing.Setup.msi" "C:\QTDev\Wi...

IIS Problems

IIS Problems IIS - requires manual Refreshing of every change.   1) "HTTP Error 500.30 - ASP.NET Core" .  Cause was files not in correct sub-folder (like \program\v1). 2) "IIS 10.0 Detailed Error - 404.0 - Not Found" . If you hand move the files but not fix registration.

Wix Installer

Wix Installer Wix v4.  Found HeatWave and FireGiant. That should get me going: https://www.firegiant.com/docs/wix/tutorial/  . Wix v4 - When right click and upgrade project from v3, it fails to put the Heat.exe to the Setup project + "Bin" folder name. If going to .NET 8: 1) Setup.wixproj -                <TargetFrameworkIdentifier>net8.0</TargetFrameworkIdentifier>       <Runtime>win-x64</Runtime> 2) Need to create a new IIS app pool that is .NET 8 and x64 (instead of x86)   If Upgrade of Existing DLL: Package.wxs -  The upgrade code is important so it uninstalls and installs over:    UpgradeCode="815d1d89-0b82-4bf2-aff4-77c7cea8a9a3