Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dasMulli's full-sized avatar

Martin Andreas Ullrich dasMulli

  • Tieto Austria
  • Vienna, Austria
View GitHub Profile
@dasMulli
dasMulli / Directory.Build.targets
Last active December 30, 2023 19:48
PublishAll target to publish for all frameworks and runtimes
<Project>
<Target Name="PublishProjectIfFrameworkSet"
DependsOnTargets="Publish"
Condition=" '$(TargetFramework)' != '' " />
<Target Name="PublishProjectForAllRIDsIfTargetFrameworkSet" Condition=" '$(TargetFramework)' != '' and '$(RuntimeIdentifiers)' != '' and '$(RuntimeIdentifier)' == '' ">
<ItemGroup>
<_PublishRuntimeIdentifier Include="$(RuntimeIdentifiers)" />
</ItemGroup>
<MSBuild Projects="$(MSBuildProjectFile)" Targets="PublishAll" Properties="TargetFramework=$(TargetFramework);RuntimeIdentifier=%(_PublishRuntimeIdentifier.Identity)" />
@dasMulli
dasMulli / build.proj
Created March 14, 2017 22:19
Sample CI build definition using MSBuild
<Project>
<ItemGroup>
<Solution Include="*.sln" />
<PublishProject Include="XXX.Mvc\XXX.Mvc.csproj" />
<TestProject Include="**\*.Test*.*proj" Exclude="XXX.Tests.Shared\XXX.Tests.Shared.csproj" />
</ItemGroup>
<Target Name="Build">
<MSBuild Projects="@(Solution)" Targets="Restore" ContinueOnError="ErrorAndStop" UnloadProjectsOnCompletion="true" UseResultsCache="false" />
<MSBuild Projects="@(PublishProject)" Targets="Publish" Properties="Configuration=Release" ContinueOnError="ErrorAndContinue" />
@dasMulli
dasMulli / traversal.proj
Created June 4, 2020 14:04
Traversal project
<Project>
<ItemGroup>
<Projects Include="$(MSBuildStartupDirectory)\**\*.*proj" />
</ItemGroup>
<Target Name="VSTest">
<Message Importance="High" Text="Found project: %(Projects.Identity)" />
<MSBuild Projects="@(Projects)" Targets="VSTest" BuildInParallel="true" SkipNonexistentTargets="true" />
</Target>
<Target Name="Restore">
<Message Importance="High" Text="Found project: %(Projects.Identity)" />
@dasMulli
dasMulli / Directory.Build.targets
Last active February 21, 2022 23:44
CI build script for a mvc + Webpack SPA app
<Project>
<Target Name="NpmInstall" Condition="Exists('package.json')">
<Exec Command="npm install" />
</Target>
<Target Name="NpmCiTest" Condition="Exists('package.json')">
<Exec Command="npm run ci-test" />
<ItemGroup Condition="'$(TestResultsOutputPath)' != ''">
<TestResultFiles Include="obj\karma-testresults\**" />
@dasMulli
dasMulli / DemoSetup.wixproj
Last active February 21, 2022 07:22
Demo wix project to publish a self-contained .NET Core app
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>91e4dc15-312a-4e90-bc1c-01de5dc99447</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>CoreConsoleAppSetup</OutputName>
<OutputType>Package</OutputType>
@dasMulli
dasMulli / Directory.Build.targets
Last active January 18, 2021 16:55
Allow `dotnet test` to be run from solution directory
<Project>
<Target Name="VSTestIfTestProject">
<CallTarget Targets="VSTest" Condition="'$(IsTestProject)' == 'true'" />
</Target>
</Project>
@dasMulli
dasMulli / Directory.Build.targets
Last active November 6, 2020 21:33
TFM based feature flags as compiler constants
<Project>
<ItemGroup>
<FeatureFlag Include="SUPPORTS_ECDSA" MinimumTargetFrameworks="netstandard1.6;net47" />
<FeatureFlag Include="SUPPORTS_GENERIC_HOST" MinimumTargetFrameworks="netcoreapp2.2;netstandard2.1" />
<FeatureFlag Include="SUPPORTS_SERVICE_PROVIDER_IN_HTTP_MESSAGE_HANDLER_BUILDER" MinimumTargetFrameworks="netcoreapp2.2;netstandard2.1" />
<FeatureFlag Include="SUPPORTS_CERTIFICATE_HASHING_WITH_SPECIFIED_ALGORITHM" MinimumTargetFrameworks="netcoreapp2.1;netstandard2.1;net48" />
</ItemGroup>
<!--
@dasMulli
dasMulli / Directory.Build.targets
Created October 17, 2020 15:51
Compiler consant for minimum framework version
<Project>
<!--
neeeds to be in Directory.Build.targets to be included
after SDK's TargetFrameworkIdentifier/-Version inference
-->
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NetCoreApp'
and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '5.0'))">
<DefineConstants>$(DefineConstants);AT_LEAST_NET5_0</DefineConstants>
</PropertyGroup>
</Project>
@dasMulli
dasMulli / Directory.Build.targets
Last active February 27, 2020 17:18
Add Git commit count to version
<Project>
<PropertyGroup>
<GenerateNuspecDependsOn>AddGitCommitCountToVersion;$(GenerateNuspecDependsOn)</GenerateNuspecDependsOn>
<!-- this is only used in NuGet 4.6.0 -->
<GetPackageVersionDependsOn>AddGitCommitCountToVersion;$(GetPackageVersionDependsOn)</GetPackageVersionDependsOn>
</PropertyGroup>
<Target Name="AddGitCommitCountToVersion"
BeforeTargets="PrepareForBuild;_GenerateRestoreProjectSpec"
Condition=" '$(DisableGitVersionSuffix)' != 'true' ">
@dasMulli
dasMulli / ns.cmd
Created February 25, 2020 13:32
Kubernetes namespace switching utility for Windows
@echo off
if "%~1"=="" GOTO PRINTNAMESPACE
: SETNAMESPACE
kubectl config set-context --current --namespace="%~1"
: PRINTNAMESPACE