Microsoft – ScottGeek Technology https://scottgeek.technology Sat, 30 Oct 2021 00:35:59 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.4 Dotnet 6 API with a HttpDelete and that 405 Method not allowed error https://scottgeek.technology/2021/10/29/dotnet-6-api-with-a-httpdelete-and-that-damn-405-not-allowed/ https://scottgeek.technology/2021/10/29/dotnet-6-api-with-a-httpdelete-and-that-damn-405-not-allowed/#respond Fri, 29 Oct 2021 16:09:12 +0000 https://scottgeek.technology/?p=5374 As we can tell from the title of the Post, we are going to talk about figuring out why in a client app one gets a Http Status code of 405 (Method Not Allowed).

When does this happen? Usually when a http request does a  http PUT or DELETE. Yet, when one uses Swagger (openAPI) or Postman to directly call the same API Delete or Put, it works!  This is starting to feel like a CORS issue, right? Read On ==>

So 405! Indeed looking at the surface of what is going on, one thinks Ah! CORS is at it again! Absolutely, this is what it feels like. After all, a Swagger/Postman GET/DELETE call under the same http domain works. But the moment one moves to a Client App coming in from a different domain (i.e. a different port on localhost, because different ports are also considered a different domain in terms of CORS), the Http PUT/DELETE stops working and throws a 405.

We are using VS2022 with Dotnet 6.0.100-rc.2.21505.57 (so the latest VS2022 and Dotnet RC 6 as of the writing of this post)

Wow… let’s step into how to rein in CORS…. We start in the API project in the Startup class.

In Configure Services =>

services.AddCors(options =>
{
    options.AddPolicy("CorsPolicy",
        builder => builder
        .AllowAnyOrigin()
        .AllowAnyHeader()
        .AllowAnyMethod()
        .WithMethods("GET","PUT","DELETE","POST","PATCH") //not really necessary when AllowAnyMethods is used.
        );
});

We build a CORS policy  (yes one can remove the .WithMethods clause)

And of course we add in the Configure method =>

app.UseRouting();
app.UseCors("CorsPolicy");

And everything is right with the world… Let’s do a Delete in a client app. Meaning we are doing HttpClient Delete to a rest url that contains the id:

Yeap a hard 405… What the what What?
After digging through lots of readings on the topic of CORS 405 PUT/DELETE, DotNet 6 issues (with not much luck), I stepped upon the answer with a bit of thinking about the problem….

In my Controller we have this as the delete method header =>

[HttpDelete("id")]
public async Task<IActionResult> Delete(int id)
{ ...

Seems simple enough, it works in the Swagger interface for testing the API. I validated that the client is using and passing the correct url and id. WHAT!?

Look closely at the [HttpDelete… tag. Notice anything? If one said, “Duh, ScottGeek- you need to wrap the “id” within {}” then YEAP!
That would be the issue. The real question is why does this seem work in the Swagger UI for the api but not in a app using HttpClient?

I have absolutely no idea why (yes I could get Fiddler out and start digging deep, nope) In this case what seems like a CORS acting up issue (405 on a cross domain request), yeah it’s not, or is it? This seems to be a bug somewhere, I suspect, in the OpenAPI (swagger) bits. Why in the OpenAPI? because it should reflect the same 405 when the API Method tag is not 100% correct.

But let’s not just pick on OpenAPI. The fact that DotNet 6 allows both [HttpDelete(“id”)] and [HttpDelete(“{id}”)] without issuing some kind of build blowup or at least a green squiggle on the one that is in error… well I give it to ya… feels like a bug.

Put the {} around the id and….

Also, don’t forget to check one’s HttpPut as well…

~SG

]]>
https://scottgeek.technology/2021/10/29/dotnet-6-api-with-a-httpdelete-and-that-damn-405-not-allowed/feed/ 0
Blazor with dotnet watch run in the Pre-Dotnet 6 and VS 2022 days https://scottgeek.technology/2021/08/10/blazor-with-dotnet-watch-run-in-the-pre-dotnet-6-and-vs-2022-days/ https://scottgeek.technology/2021/08/10/blazor-with-dotnet-watch-run-in-the-pre-dotnet-6-and-vs-2022-days/#respond Tue, 10 Aug 2021 17:59:46 +0000 https://scottgeek.technology/?p=5352 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

]]>
https://scottgeek.technology/2021/08/10/blazor-with-dotnet-watch-run-in-the-pre-dotnet-6-and-vs-2022-days/feed/ 0
BCP and Clustered SQL Oh the Errors https://scottgeek.technology/2021/08/05/bcp-and-clustered-sql-oh-the-errors/ https://scottgeek.technology/2021/08/05/bcp-and-clustered-sql-oh-the-errors/#respond Thu, 05 Aug 2021 21:58:00 +0000 https://scottgeek.technology/?p=5350 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

 

]]>
https://scottgeek.technology/2021/08/05/bcp-and-clustered-sql-oh-the-errors/feed/ 0
Micro Build 2021 Is Here! https://scottgeek.technology/2021/05/25/micro-build-2021-is-here/ https://scottgeek.technology/2021/05/25/micro-build-2021-is-here/#respond Tue, 25 May 2021 16:29:38 +0000 https://scottgeek.technology/?p=5321 YES Build is here! I’m really liking the Backpack!

~ScottGeek

]]>
https://scottgeek.technology/2021/05/25/micro-build-2021-is-here/feed/ 0
A slight issue when one wants to install SQL 2019 Dev, etc The ODBC 17 SQL Driver https://scottgeek.technology/2021/04/19/i-slight-issue-when-one-wants-to-install-sql-2019-dev-etc-the-odbc-17-sql-driver/ https://scottgeek.technology/2021/04/19/i-slight-issue-when-one-wants-to-install-sql-2019-dev-etc-the-odbc-17-sql-driver/#respond Mon, 19 Apr 2021 21:54:41 +0000 https://scottgeek.technology/?p=5311 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

]]>
https://scottgeek.technology/2021/04/19/i-slight-issue-when-one-wants-to-install-sql-2019-dev-etc-the-odbc-17-sql-driver/feed/ 0
The world of Dotnet Templates https://scottgeek.technology/2021/01/21/the-world-of-dotnet-templates/ https://scottgeek.technology/2021/01/21/the-world-of-dotnet-templates/#respond Thu, 21 Jan 2021 21:35:51 +0000 https://scottgeek.technology/?p=5272 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

]]>
https://scottgeek.technology/2021/01/21/the-world-of-dotnet-templates/feed/ 0
Dot Net 5 is Here… Check it out. https://scottgeek.technology/2020/11/11/dot-net-5-is-here-check-it-out/ https://scottgeek.technology/2020/11/11/dot-net-5-is-here-check-it-out/#respond Thu, 12 Nov 2020 01:17:33 +0000 https://scottgeek.technology/?p=5253 Wow… some most excellent videos on what is what in .Net 5! Check it out on

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

You can also find these on You Tube… search on .Net 5. The Conf 2020 Days 1-3 will be there…

~ScottGeek.

]]>
https://scottgeek.technology/2020/11/11/dot-net-5-is-here-check-it-out/feed/ 0
Backing up your WSL Distro and Copying it to another PC https://scottgeek.technology/2020/10/17/backing-up-your-wsl-distro-and-copying-it-to-another-pc/ https://scottgeek.technology/2020/10/17/backing-up-your-wsl-distro-and-copying-it-to-another-pc/#respond Sat, 17 Oct 2020 19:11:56 +0000 https://scottgeek.technology/?p=5219 In our last article we talked about Moving an install WSL Distro from it awful install folder to another drive and path. So let’s make a back up of that distro, and then install it on a different PC.

Using our new favorite tool LxRunOffline let’s make back up of a distro on our PC.

However, as one starts down the path of using LxRunOffline, there is a slight issue when it comes to WSL2 Distros:

lxrunoffline export -n openSUSE-Leap-15-1 -f suse.tar.gz
[ERROR] The action/argument “export” doesn’t support WSL2.

Ok, not a huge problem… this article just got longer…. LxRunOffline export will work for WSL 1 type Distros… So let’s do an example of both using LxRunOffline and WSL utilities.

For WSL 1 type Distros:

LxRunOffline has a command called List- from a Powershell window my list looks like this

LxRunOffline.exe list

fedoraremix
docker-desktop
Debian
Ubuntu-18.04
Ubuntu
openSUSE-Leap-15-1
docker-desktop-data
WLinux
Ubuntu-20.04
kali-linux

Now the LX tool has a command to do a backup. This collects the distro into a Linux tar file (in Linux terms a compressed tape file).

LxRunOffline export –n <NameOfDistro> –f <pathAndNameOfExportFile>

That’s the general format of the export.

Now before one goes about exported a Distro – I would really do a WSL –shutdown Why? I think it’s best not to have any Distro’s running when you are trying to export them. It’s not a 100% required, but it is a good practice.

For WSL 2 type Distros:

Still do the WSL –shutdown.

Now we use the WSL command to backup the Distro. Like the LX tool, WSL has basically the same set of commands.
Get a list of Distros with:

wsl --list
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
fedoraremix
docker-desktop
Debian
Ubuntu-18.04
Ubuntu
openSUSE-Leap-15-1
docker-desktop-data
WLinux
kali-linux

And the backup command for WSL:

wsl --export WLinux .\PengWin.tar.gz

dir

    Directory: D:\cse.Linux

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          10/17/2020 12:46 PM     9039769600 PengWin.tar.gz

Now we have in either case a copy of our Distro that can be imported on another PC with WSL.

When using WSL.exe

WSL

--import <Distro> <InstallLocation> <FileName> [Options]
        Imports the specified tar file as a new distribution.
        The filename can be - for standard input.

        Options:
            --version <Version>
                Specifies the version to use for the new distribution.

The –import command  Allows one to name the Distro, install to a location, from a filename. The options here, –version allows one to change the WSL version while it’s being imported.

Now LXRunOffline is a little different:

lxrunoffline install

Options:
  -n arg                Name of the distribution
  -d arg                The directory to install the distribution into.
  -f arg                The tar file containing the root filesystem of the
                        distribution to be installed. If a file of the same
                        name with a .xml extension exists and "-c" isn't
                        specified, that file will be imported as a config file.
  -r arg                The directory in the tar file to extract. This argument
                        is optional.
  -c arg                The config file to use. This argument is optional.
  -v arg (=2)           The version of filesystem to use, latest available one
                        if not specified.
  -s                    Create a shortcut for this distribution on Desktop.


As we see the install command has a few more options beyond Name, Directory, and tar filename.

Happy WSL’ing,

Prev Article: Moving your installed WSL Linux Distro

Go Back to Index of WSL articles

~SG

]]>
https://scottgeek.technology/2020/10/17/backing-up-your-wsl-distro-and-copying-it-to-another-pc/feed/ 0
Moving your installed WSL Linux Distro https://scottgeek.technology/2020/10/15/moving-your-installed-wsl-linux-distro/ https://scottgeek.technology/2020/10/15/moving-your-installed-wsl-linux-distro/#comments Thu, 15 Oct 2020 16:00:24 +0000 https://scottgeek.technology/?p=5212 Why start this series with moving Distro’s around and not just about installing? Simple, The distro’s tend to default their install on the C: drive in the login user App Data space (don’t even get me started on over loading c:\users\<YourUserName>).

So what’s the problem with c:\users\<YourUserName>\AppData\Local?  where do I begin… protected? hidden? Filling up your c: drive… pick one. But the most annoying one when it comes to Windows WSL distros… the install places these in the package folder. So c:\users\<YourUserName>\AppData\Local\Packages, and it does it in a way that usually involves a GUID like naming… Get the picture?

Ok, enough harping on it… Let’s get to moving things about.

You start with getting the most handy little utility called LxRunOffline. You can go to their GitHub page:

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

Lots of mucking about with install verbiage (that’s a bit on the side of… yeah you really don’t need to do all of that on windows 10). Just go to the release page and download the zip file already:

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

Unzip to a favorite directory… one that is in your execute path works fine. This gives one a exe that will execute from either a command window or powershell.

So let’s step through it…

First go ahead and install one or more of your favorite distros for WSL.

Next we move it….

##
##  We will do this in Powershell
##
##  Start with choosing a place we want our distro's to live... in my case the root distro I do is D:\cseWSL\<distroName>
##

## Find your user
##
D:\>whoami

## I get something like
mysystem\scott

## Next for the location you wish to move the distro to... i.e. in my case d:\cseWSL\Ubuntu18
## I'm doing my Ubuntu 18.04 
##  We set some access control to that directory
icacls d:\cseWSL\Ubuntu18 /grant "scott:(OI)(CI)(F)"
## Here we are setting some inheriate properties and full file access to my user
## you can lookup icacls and what those parameters are from the internet

## Finding out what the distro names are
##
LxRunOffline list 

Ubuntu

##This is same as the WSL -l  command

## You can list the current location of a distro using
LxRunOffline get-dir -n Ubuntu
## The -n <distro Name> is required for the get-dir command
## For my Fedora distro I get something like this
....  \AppData\Local\Packages\WhitewaterFoundryLtd.Co.FedoraRemixforWSL_kd1vv0z0vy70w\LocalState

## Now the magic part... Moving a distro
LxRunOffline move -n Ubuntu -d d:\cseWSL\Ubuntu18
##  the -n and -d are required for the move command
##  if the named distro exists and the directory exists, then this will move the distro over
##
## To check that everything is ok with the move
## Do another LxRunOffline get-dir -n
## and see the new location
##
## Then of course, run your distro to make sure it starts up
## LxRunOffline provides a run command
LxRunOffline run -n Ubuntu

## Or start the moved distro in the normal way


 


Seems a little much to do… but not really.  It comes down to Create a Directory destination, set some permissions, and then run a command.

There we are… distros located in a Happy Place.

Next up: Backing up your WSL Distro and Copying it to another PC

Back to Index of WSL Articles

~SG

 

 

]]>
https://scottgeek.technology/2020/10/15/moving-your-installed-wsl-linux-distro/feed/ 1
WSL Linux on Windows 10 Series of Articles https://scottgeek.technology/2020/10/15/wsl-linux-on-windows-10-series-of-articles/ https://scottgeek.technology/2020/10/15/wsl-linux-on-windows-10-series-of-articles/#respond Thu, 15 Oct 2020 15:59:18 +0000 https://scottgeek.technology/?p=5210 Ok it’s time to start a series on WSL.

I make no apologies when I say I’m not huge Linux fan, but I’m also not lacking when it comes to understanding how to utilize this OS in my Microsoft world.

First off, I’m not a newbie when it comes to matters of Linux or Unix- I spent a number of years working on HP UX with Window-X/Motif apps I had to support (so to all the Linux Trolls… yeah whatever).

So why is a “Microsoft Heavy” a.k.a. Me, ScottGeek bothering with the Linux side? Simple, over the past few years with MS moving to an inclusive approach with it’s Development tooling for cross OS apps, why wouldn’t I add Linux to my stack? Now don’t get me wrong, I’m not about to start writing code in Java or some other fork of the C language beyond C#.  But Linux as a OS to deploy apps on, Linux as an IOT host, Linux as an place to share my API’s that the non-MS folks want to use- yeah that works.

So shall we begin with some topics on WSL:

Moving your installed WSL Linux Distro
Backing up your WSL Distro and Copying it to another PC

~SG

]]>
https://scottgeek.technology/2020/10/15/wsl-linux-on-windows-10-series-of-articles/feed/ 0