• Blazor,  Microsoft

    Blazor with dotnet watch run in the Pre-Dotnet 6 and VS 2022 days

    Oh, how we do wait for the release of dotnet 6 and most important VS 2022. Why? Well the promise of hot-reload without hoops to jump through.

    For the most part in VS 2019 16.10.4, “hot-reload” of a Blazor app is not too bad <= Circle that “not too bad”- it does actually work… mostly! Yes, I do refer to the “dotnet watch run”. It does detect changes in your Blazor files and reload the browser page… yeah, BUT it does have issues. Here comes the list….

    It doesn’t detect new files added… go ahead add a new razor page while your project is in “dotnet watch run” – nope it will not find it no matter how many times you hard refresh the browser. Not only razor pages, but new stylesheets- yeap, it’s not going to find those either!

    It has issues when you make too many complicated changes in your code. Yes compile errors that don’t go away.

    It interferes with an already “flaky” intellicode/intellisense… My goodness talking about annoying! Already half the time, bootstrap intellisense stops working on razor pages. And what the hell happened to code snippets? (Probably less about hot-reload than this version of VS being riddled with bugs!)

    Ok, I’m mostly over that now…. deep breath… 1…2…3…4… Alright.

    Let’s get to the point, the matter of always having to type in that “dotnet watch run”, stop it, and type it in again… what’s the point? Let’s create a launch profile so that we can tack this into VS (gee you think the Blazor Template should already have that? Yeap it should). Here we go:

     

    "Watch": {
          "commandName": "Executable",
          "launchBrowser": true,
          "launchUrl": "http://localhost:5000/",
          "commandLineArgs": "watch run",
          "workingDirectory": "$(ProjectDir)",
          "executablePath": "dotnet.exe",
          "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
          }
        }

    In your launchSettings.Json file, place the code above in the “Profile” section…. Match sure this is in the “PROFILE” section!

    Now let the magic begin… well mostly… When you tap the “Watch” on the Build/Debug drop down… that lovely “dotnet watch run” will execute in a window… and now you to can experience the “buggy” hot-reload of a Blazor app. 😎
    ~SG

  • Microsoft,  SQL Server

    BCP and Clustered SQL Oh the Errors

    I got a curious message concerning problems that someone from work was having issues getting a relatively simple BCP (Bulk Copy for SQL) to work.

    So here we go:

    bcp "select top 5 [Data] from [ADataBase].[dbo].[ATable]  where [ProcessedTime] <= GetDate()-1 and MessageType=''SomeProduct'' order by [ProcessedTime] desc for xml raw, root(''MyexportRoot'')"' +
        ' QUERYOUT ""B:\BCPBatch\Data\sample.xml"" -T -c  -S TheSQL\Instance';
    

    It’s a little complicated… Basically pull data from a table in DB on a SQL Instance… and output as xml to an xml file.
    After spending, a few hours, getting all kinds of errors about drive not found, path not found, can’t open the file… bah bah bah. It’s like what the hell?!

    You take that statement and execute it on a console window or powershell window… and no problems, but you get into SSMS, and in a query window… and nothing but errors… So something like this:

    EXECUTE sp_configure 'show advanced options', 1;  
    GO  
    -- To update the currently configured value for advanced options.  
    RECONFIGURE;  
    GO  
    -- To enable the feature.  
    EXECUTE sp_configure 'xp_cmdshell', 1;  
    GO  
    -- To update the currently configured value for this feature.  
    RECONFIGURE;  
    GO  
    
      declare @cmd nvarchar(512);
    -- Please note that the fully qualified table name is needed
    select @cmd = 'bcp "select top 5 [Data] from [ADataBase].[dbo].[ATable] where [ProcessedTime] <= GetDate()-1 and MessageType=''SomeProduct'' order by [ProcessedTime] desc for xml raw, root(''MyexportRoot'')"' + ' QUERYOUT ""B:\BCPBatch\Data\sample.xml"" -T -c -S TheSQL\Instance';
    exec xp_cmdshell @cmd;
    go
    
    EXECUTE sp_configure 'xp_cmdshell', 0;  
    GO  
    -- To update the currently configured value for this feature.  
    RECONFIGURE;  
    GO  
    
    EXECUTE sp_configure 'show advanced options', 0;  
    GO  
    

    And let the errors happen… and they do. What’s the issue here… well nothing really with the code, but with the fact that my TheSql\Instance was in fact Clustered!

    So why is that a problem? It’s this part here:

    QUERYOUT “”B:\BCPBatch\Data\sample.xml””   – the syntax is correct, but on a clustered server file locations are problematic! Meaning, the cluster does not normally have full access to all of the drives. Now, will a network share work? Not sure. I didn’t test that.

    The solution I suggested was to move to another SQL instance that was not clustered, and the script worked.
    ~SG

     

  • Microsoft,  SQL Server

    A slight issue when one wants to install SQL 2019 Dev, etc The ODBC 17 SQL Driver

    On my way to getting the latest SQL Server installed on one of my Dev PC’s- I ran across the issue of getting prompt for:

    msoledbsql.msi

    What the hell…

    ODBC Driver 17 is what that is about. Apparently, the SQL installed is not smart enough to know that one already has ODBC 17 SQL Driver installed and runs into a major “cannot resolve” the problem. The end result is that one does not get the SQL instance installed…

    But after reading lots of “not really helping” blurbs from the Internet, the Solution is simple… well mostly.

    You have to uninstall the “Microsoft ODBC Driver 17 for SQL Server” – one can find it on windows 10 in the APPS & Features. Uninstall it and redo the SQL install. One should have better luck with moving forward with getting SQL installed…

    ~ScottGeek

  • Community Stand up Links

    More Blazor talk from the Community Stand up

    Links from the show.

    [visual-link-preview encoded=”eyJ0eXBlIjoiZXh0ZXJuYWwiLCJwb3N0IjowLCJwb3N0X2xhYmVsIjoiIiwidXJsIjoiaHR0cHM6Ly93d3cudGhldXJsaXN0LmNvbS9tYXJjaC05LWNvbW11bml0eS1saW5rcyIsImltYWdlX2lkIjotMSwiaW1hZ2VfdXJsIjoiaHR0cHM6Ly93d3cudGhldXJsaXN0LmNvbS9pbWFnZXMvbG9nby5wbmciLCJ0aXRsZSI6IlRoZSBVcmxpc3QgLSBDb250cmlidXRlIHRvIEJsYXpvciBMaW5rcyIsInN1bW1hcnkiOiJBU1AuTkVUIENvbW11bml0eSBTdGFuZHVwIC0gSG93IHRvIGNvbnRyaWJ1dGUgdG8gQmxhem9yIiwidGVtcGxhdGUiOiJ1c2VfZGVmYXVsdF9mcm9tX3NldHRpbmdzIn0=”]

  • Community Stand up Links

    Community links for .net Network API community standup

    [visual-link-preview encoded=”eyJ0eXBlIjoiZXh0ZXJuYWwiLCJwb3N0IjowLCJwb3N0X2xhYmVsIjoiIiwidXJsIjoiaHR0cHM6Ly93d3cudGhldXJsaXN0LmNvbS9hc3BuZXQtc3RhbmR1cC0yMDIxLTAyLTE2IiwiaW1hZ2VfaWQiOi0xLCJpbWFnZV91cmwiOiJodHRwczovL3d3dy50aGV1cmxpc3QuY29tL2ltYWdlcy9sb2dvLnBuZyIsInRpdGxlIjoiVGhlIFVybGlzdCAtIC5uZXQgbmV0d29yayBBUEkiLCJzdW1tYXJ5IjoiTGlua3MgZnJvbSBDb21tdW5pdHkgU3RhbmR1cCAyMDIxLTAyLTE2IiwidGVtcGxhdGUiOiJ1c2VfZGVmYXVsdF9mcm9tX3NldHRpbmdzIn0=”]

    And

    [visual-link-preview encoded=”eyJ0eXBlIjoiZXh0ZXJuYWwiLCJwb3N0IjowLCJwb3N0X2xhYmVsIjoiIiwidXJsIjoiaHR0cHM6Ly93d3cudGhldXJsaXN0LmNvbS9hc3BuZXQtc3RhbmR1cC0yMDIxLTAyLTIzIiwiaW1hZ2VfaWQiOi0xLCJpbWFnZV91cmwiOiJodHRwczovL3d3dy50aGV1cmxpc3QuY29tL2ltYWdlcy9sb2dvLnBuZyIsInRpdGxlIjoiVGhlIFVybGlzdCAtIFNoYXJlIHRoZSBpbnRlcm5ldCIsInN1bW1hcnkiOiJHcm91cCBsaW5rcyB0b2dldGhlciBpbiBhIGxpc3QgYW5kIGdldCBhIGN1c3RvbSBVUkwgdG8gc2hhcmUgdGhlbS4gRWRpdCB5b3VyIGxpc3RzIGF0IGFueSB0aW1lLiIsInRlbXBsYXRlIjoidXNlX2RlZmF1bHRfZnJvbV9zZXR0aW5ncyJ9″]

  • Community Stand up Links

    Community links for the February 9th edition of the Blazor community standup

    [visual-link-preview encoded=”eyJ0eXBlIjoiZXh0ZXJuYWwiLCJwb3N0IjowLCJwb3N0X2xhYmVsIjoiIiwidXJsIjoiaHR0cHM6Ly93d3cudGhldXJsaXN0LmNvbS9mZWItOS1jb21tdW5pdHktbGlua3MiLCJpbWFnZV9pZCI6LTEsImltYWdlX3VybCI6Imh0dHBzOi8vd3d3LnRoZXVybGlzdC5jb20vaW1hZ2VzL2xvZ28ucG5nIiwidGl0bGUiOiJUaGUgVXJsaXN0IC0gQmxhem9yIExpbmtzIiwic3VtbWFyeSI6Ikxpbmsgc2l0ZXMgZm9yIEJsYXpvciIsInRlbXBsYXRlIjoic2ltcGxlIn0=”]

  • GitHub

    The GitHub Secret thing

    So you travel along in your or someone’s GitHub repo… and we all know what that looks like. The repo code, actions, etc. But did you know that you can make the GitHub Web UI (page) look like a VS Code File Explorer? Ya… you can. It’s not really supported by GitHub (just to be clear)… but yeah.

    What is magic…

    Normally a GitHub url looks something like https://github.com/<User Name>/<Repo Name> simple enough…
    To see the magic… just do a https://github1s.com/<User Name>/<Repo Name>
    That’s right, add a 1s to the DNS name of github.com… You will get a VS Code “On-Line” view of the repo. How cool is that? 😎

    Look in the GH repo: conwnet/github1s

    ~SG

  • .Net,  Microsoft

    The world of Dotnet Templates

    I have long been using templates for dotnet new and of course Visual Studio. So I’ve started down the road of creating my own templates… or a least trying to understand how to create these,

    Now creating templates for dotnet new and especially for Visual Studio has never been a simple task. But let us try.

    The first matter is understanding where templates live. For the most part these are based on your user for your PC. This found by using a PS command:

    join-path -Path $env:USERPROFILE -ChildPath .templateengine

    This will return C:\Users\<your user name>\.templateengine   And as you guess it, there is a .templateengine directory in your users directory. What does that mean, well simply put, when one does a .dotnet new –install, application templates get installed for your user. These actually live in that directory space. Simple enough.

    When you start developing your own templates, you need to be careful, because the list of templates can get very long. That may or may not be a problem.
    A handy PS script to clear out installed templates and put it back to the original set of templates:

    function Reset-Templates{
        [cmdletbinding()]
        param(
            [string]$templateEngineUserDir = (join-path -Path $env:USERPROFILE -ChildPath .templateengine)
        )
        process{
            'resetting dotnet new templates. folder: "{0}"' -f $templateEngineUserDir | Write-host
            get-childitem -path $templateEngineUserDir -directory | Select-Object -ExpandProperty FullName | remove-item -recurse
            &dotnet new --debug:reinit
        }
    }

    Keep in mind, this clears out all templates you have installed under your user. Use with care. If you have a set of favorite templates… yeap, they will get cleared off too!

    Now, where to start? I would go to Sayed’s GitHub repo @

    [visual-link-preview encoded=”eyJ0eXBlIjoiZXh0ZXJuYWwiLCJwb3N0IjowLCJwb3N0X2xhYmVsIjoiIiwidXJsIjoiaHR0cHM6Ly9naXRodWIuY29tL3NheWVkaWhhc2hpbWkvdGVtcGxhdGUtc2FtcGxlIiwiaW1hZ2VfaWQiOi0xLCJpbWFnZV91cmwiOiJodHRwczovL2F2YXRhcnMuZ2l0aHVidXNlcmNvbnRlbnQuY29tL3UvMTI4MzE1ND9zPTQwMCZ2PTQiLCJ0aXRsZSI6IlRlbXBsYXRlIFNhbXBsZSBieSBTYXllZCIsInN1bW1hcnkiOiJUaGlzIHJlcG8gY29udGFpbnMgYSBjb3VwbGUgc2FtcGxlcyBzaG93aW5nIGhvdyB5b3UgY2FuIGNyZWF0ZSBhIC5uZXQgY29yZSB0ZW1wbGF0ZSB0aGF0IGNhbiBiZSB1c2VkIGVpdGhlciBieSB0aGUgZG90bmV0IGNvbW1hbmQgbGluZSAoZG90bmV0IG5ldykgb3IgVmlzdWFsIFN0dWRpbyAmIFZpc3VhbCBTdHVkaW8gZm9yIE1hYy4iLCJ0ZW1wbGF0ZSI6InVzZV9kZWZhdWx0X2Zyb21fc2V0dGluZ3MifQ==”]

    It’s a long read, but one can also go over to Channel9 and look for the video series that steps one through the process.

    Another handy resource to search for templates is a web site:

     

    [visual-link-preview encoded=”eyJ0eXBlIjoiZXh0ZXJuYWwiLCJwb3N0IjowLCJwb3N0X2xhYmVsIjoiIiwidXJsIjoiaHR0cHM6Ly9kb3RuZXRuZXcuYXp1cmV3ZWJzaXRlcy5uZXQvIiwiaW1hZ2VfaWQiOi0xLCJpbWFnZV91cmwiOiJodHRwczovL2F2YXRhcnMyLmdpdGh1YnVzZXJjb250ZW50LmNvbS91LzI2Nzg4NTgiLCJ0aXRsZSI6ImRvdG5ldCB0ZW1wbGF0ZXMiLCJzdW1tYXJ5IjoiU2l0ZSBmb3IgZmluZGluZyBkb3RuZXQgdGVtcGxhdGVzLiIsInRlbXBsYXRlIjoidXNlX2RlZmF1bHRfZnJvbV9zZXR0aW5ncyJ9″]

    Enjoy
    ~ScottGeek