Skip to content

Instantly share code, notes, and snippets.

View sayedihashimi's full-sized avatar

Sayed Ibrahim Hashimi sayedihashimi

View GitHub Profile
@sayedihashimi
sayedihashimi / resolve-fullpath.ps1
Created August 5, 2014 09:11
PowerShell how to convert a relative path to a full path
# based off of http://mnaoumov.wordpress.com/2013/08/21/powershell-resolve-path-safe/
function Resolve-FullPath{
[cmdletbinding()]
param
(
[Parameter(
Mandatory=$true,
Position=0,
ValueFromPipeline=$true)]
[string] $path
@sayedihashimi
sayedihashimi / fix-package-path.wpp.targets
Last active October 4, 2020 13:48
MSBuild wpp.targets file to fix the long path in web packages from Visual Studio
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PackagePath Condition=" '$(PackagePath)'=='' ">website</PackagePath>
<EnableAddReplaceToUpdatePacakgePath Condition=" '$(EnableAddReplaceToUpdatePacakgePath)'=='' ">true</EnableAddReplaceToUpdatePacakgePath>
<PackageDependsOn>
$(PackageDependsOn);
AddReplaceRuleForAppPath;
</PackageDependsOn>
@sayedihashimi
sayedihashimi / get-full-path.proj
Created December 23, 2012 23:06
Demonstrates how you can convert a relative path to an absolute path in MSBuild
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Demo">
<!-- Demonstrates how you can convert a relative path to a full path in MSBuild -->
<PropertyGroup>
<Filepath>sample\file.txt</Filepath>
</PropertyGroup>
<Target Name="Demo">
<PropertyGroup>
@sayedihashimi
sayedihashimi / Get-CurrentBranch.ps1
Created July 16, 2020 20:05
Get-CurrentBranch powershell function
function Get-CurrentBranch{
[cmdletbinding()]
param()
process{
[string]$result = &git branch --show-current
if(-not $result){
$result = $result.trim();
}
$result
}

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
<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 / web.config
Created March 28, 2012 00:38
How to enable directory browsing in web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
@sayedihashimi
sayedihashimi / elapsed-time.proj
Created July 28, 2014 21:28
msbuild get elapsed time
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
This shows how you can calculate the elapsed time in MSBuild
-->
<Target Name="BeforeBuild">
<PropertyGroup>
<startTime>$([System.DateTime]::Now)</startTime>
@sayedihashimi
sayedihashimi / add-function-with-param.ps1
Created February 3, 2014 05:57
PowerShell: Add a function with a parameter to an object
$result | Add-Member -MemberType ScriptMethod ExpandString -Value {
[cmdletbinding()]
param(
[Parameter(
Mandatory=$true)]
[string]
$unexpandedValue
)
process{
if($this.ProjectInstance){
@sayedihashimi
sayedihashimi / extract-interface.gif
Last active November 8, 2018 21:13
Some sample Quick Fix actions available in Visual Studio for Mac
extract-interface.gif