Skip to content

Instantly share code, notes, and snippets.

Avatar

Sayed Ibrahim Hashimi sayedihashimi

View GitHub Profile
@sayedihashimi
sayedihashimi / Get-CurrentBranch.ps1
Created Jul 16, 2020
Get-CurrentBranch powershell function
View Get-CurrentBranch.ps1
function Get-CurrentBranch{
[cmdletbinding()]
param()
process{
[string]$result = &git branch --show-current
if(-not $result){
$result = $result.trim();
}
$result
}
View dotnet-tool-target.md

Add the target below to the project file for your dotnet core global tool. You can run this target to simplify reinstalling the global tool. You can execute this target with dotnet build -t:InstallTool.

When this target is executed the following will happen (in this order):

  • Project is packed into a NuGet package
  • Tool is uninstalled with dotnet tool uninstall
  • Tool is installed with dotnet tool install
  • Help is called on the tool just installed
View snippet for juan
<ItemGroup>
<!-- Don't publish the SPA source files, but do show them in the project files list -->
<Content Remove="$(SpaRoot)**" />
<!-- remove duplicate .json files from Content -->
<Content Remove="appsettings.json;appsettings.Development.json;bundleconfig.json" />
<Content Include="appsettings.json" Condition="Exists('appsettings.json')" />
<Content Include="appsettings.Development.json" Condition="Exists('appsettings.Development.json')" />
<Content Include="bundleconfig.json" Condition="Exists('bundleconfig.json')" />
<!-- remove .ts files from None, they should be in TypeScriptCompile instead -->
<None Remove="**/*.ts" />
@sayedihashimi
sayedihashimi / extract-interface.gif
Last active Nov 8, 2018
Some sample Quick Fix actions available in Visual Studio for Mac
@sayedihashimi
sayedihashimi / limit-nuget.md
Last active Jul 6, 2018
how to limit nuget packages and versions to specific ones
View limit-nuget.md

Question: How can I ensure that all projects only use a specific set of nuget packages and versions? I'm using VS2017.

The way that I would handle this is to add a (directory.build.targets)[https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build#directorybuildprops-and-directorybuildtargets] to help in this scenario.

The idea is that you will add an msbuild .targets file in the source root named directory.build.targets. In that file you can inject a target to be run before the build starts. For example,

@sayedihashimi
sayedihashimi / how-to-publish-to-multiple-iis.md
Last active Jun 25, 2018
How to publish a web project to multiple IIS sites
View how-to-publish-to-multiple-iis.md

Scenario:

  • I have a web project that I want to publish to multiple IIS sites
  • Publish in VS should publish to devs local IIS server (MSDeploy)
  • Publish from CI/CLI should publish to remote env (MSDeploy)
  • CI/CLI and VS publish should be the same
  • Building the solution takes ~3 min and should only be performed once
  • Config files need to be transformed based on the dest env

Question:

How can I accomplish this?

@sayedihashimi
sayedihashimi / dotnet-new-templates.txt
Last active Jul 24, 2017
Templates availabe on nuget.org for dotnet new
View dotnet-new-templates.txt
--- template report ---
Name DownloadCount Percent overall
---- ------------- ---------------
Microsoft.AspNetCore.SpaTemplates 44876 65.4 %
Microsoft.DotNet.Web.Spa.ProjectTemplates 6253 9.1 %
libyear 1860 2.7 %
Boilerplate.Templates 1600 2.3 %
IdentityServer4.Templates 1136 1.7 %
Amazon.Lambda.Templates 1122 1.6 %
@sayedihashimi
sayedihashimi / dotnet-new-ux.ps1
Last active Mar 1, 2018
dotnet new user interaction
View dotnet-new-ux.ps1
[cmdletbinding()]
param()
# to run this script:
# (new-object Net.WebClient).DownloadString("https://gist.githubusercontent.com/sayedihashimi/899ed1a47953ea6a45f60220687cfdd6/raw/b3ad6ab230b5c4a9cf5b39d3142fc7b36df8c54f/run-dotnetnew-ux.ps1") | iex
function StartDefault{
[cmdletbinding()]
param()
process{
View machine-setup.ps1
[cmdletbinding()]
param()
$global:machinesetupconfig = @{
MachineSetupConfigFolder = (Join-Path $env:temp 'SayedHaMachineSetup')
MachineSetupAppsFolder = (Join-Path $env:temp 'SayedHaMachineSetup\apps')
BaseChocoPackages = @(
'boxstarter',
'boxstarter.winconfig'
'git.install',
@sayedihashimi
sayedihashimi / download-tablebases
Created Sep 18, 2016
Download Nalimov table bases (3/4/5)
View download-tablebases
[cmdletbinding()]
param()
function DownloadTablebases{
[cmdletbinding()]
param(
$baseUrl = 'http://www.chesskit.com/download/nalimov',
$allFilename = 'all.txt',
$downloadRoot = ($pwd)
)
You can’t perform that action at this time.