Category: powershell

See the tests in VSCode and improvements in powershell–part 24

I wanted that the user can see the tests when running in  VSCode. So in devcontainer.json I have put

“extensions”: [
“ms-vscode.csharp”
“ms-vscode.csharp”,
“hbenl.vscode-test-explorer”,
“formulahendry.dotnet-test-explorer”
]

and in the settings.json on .vscode folder

 

dotnet-test-explorer.enableTelemetry”: false,
“dotnet-test-explorer.testProjectPath”:”**/*.sln”,
“dotnet-test-explorer.autoExpandTree”:true

 

So far, so good. But – I remember that powershell have a problem. And I figure why – before running

dotnet pwsh

I should run

dotnet tool restore

in order to run the dotnet-toolsjson from .config file

 

{

“version”: 1,

“isRoot”: true,

“tools”: {

“powershell”: {

“version”: “6.2.3”,

“commands”: [

“pwsh”

]

}

}

}

 

.And this command should be executed both in Docker and in Azure

And one hour passes...
(This is the result of 1 hour per day auto-challenge as a full cycle developer for an exchange rates application)
( You can see the sources at https://github.com/ignatandrei/InfoValutar/ )
NrPost 
1Start
2Reading NBR from internet
3Source control and build
4Badge and test
5CI and action
6Artifacts and dotnet try
7Docker with .NET Try
8ECB
9Intermezzo - Various implementations for programmers
10Intermezzo - similar code - options
11Plugin implementation
12GUI for console
13WebAPI
14Plugin in .NET Core 3
15Build and Versioning
16Add swagger
17Docker - first part
18Docker - second part
19Docker - build Azure
20Pipeline send to Docker Hub
21Play with Docker - online
22Run VSCode and Docker
23Deploy Azure
24VSCode see tests and powershell
25Code Coverage
26Database in Azure
27Sql In Memory or Azure
28Azure ConString, RSS
29Middleware for backward compatibility

Powershell vs console application

I have decided to make the utilities that I use in form of Powershell applications instead of Windows / Console applications

Pros:

There are simpler to use  – just run the powershell

The parsing of command line is powerfull in powershell

There are simpler to maintain ( just text scripts files)

There are no big dependencies( .NET Core/ .NET 4.x  to be installed)

This is a good tool under  my toolbelt

Everything you do in .NET you can do in Powershell ( sometimes it is much harder in .NET rather then powershell)

 

The repository is https://github.com/ignatandrei/PowershellUtils and the first item is to move the big files from C: into another drive to free space by making a junction dir ( e.g. C:\ProgramData\Package Cache and C:\Windows\Installer )

WifiHotSpot

 

I have become tired of reading about how to enable Wifi HotSpot in Windows 10 . The reference is here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd815243%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 . ( also, for bandwidth throttling you can try  https://github.com/jagt/clumsy and / or https://reqrypt.org/windivert.html   )

I was trying to make a Windows Store application – but, apparently, it is very difficult to run command lines application from Windows Store/

So I made a small powershell file ( hosted at https://github.com/ignatandrei/WIFIHotSpot )

Enjoy!

Powershell and always use explicit

 

Let’s suppose you have a variable $x=”http://msprogrammer.serviciipeweb.ro/

In powershell the following are the same

$x

Write-Host $x

 

I want to make a function that returns a value . Let’s say

Function Add([string] $a, [string]$b)

{

#debug to see arguments

$a

$b

return $a + $b

}

 

If I call this function with

Add 10 17 # the syntax for calling powershell is WITHOUT comma – the comma indicates arry

it shows

10

17

27

However , if I wrote

$x = Add 10 17

it does not wrote

10

17

 

Do you know why ?

 

Answer in the first comment

powershell and clean iis

Sometimes it is necessary to remove IIS temp files from windows directory

So I have made this following script in powershell

iis reset

What it does:
restarts iis ( run as admin in Windows 7)

Cleans temporary folders from

$windir + “\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files”

$windir + “\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files”

Enjoy !(iis reset)

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.