Skip to content

Instantly share code, notes, and snippets.

@Serivy
Serivy / LDownloadFile.Targets
Last active November 8, 2019 07:43
MSBuild web download task which only downloads newer
<UsingTask TaskName="LDownloadFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<Url ParameterType="System.String" Required="true" />
<File ParameterType="System.String" Required="false" />
<OutputFolder ParameterType="System.String" Required="false" />
<OnlyIfNewer ParameterType="System.Boolean" Required="false" />
</ParameterGroup>
<Task>
<Using Namespace="System.Web"/>
<Code Type="Fragment" Language="cs"><![CDATA[
@Serivy
Serivy / GenerateCordovaResouces.ps1
Created January 24, 2018 05:52
Generates Cordova resources from 2 base images.
Add-Type -AssemblyName System.Drawing
function Process
{
Param($In, $OutFile, $Square, $W, $H, $BG, $ResizeW)
$file = Get-Item $In
$img = [System.Drawing.Image]::FromFile($file)
# Set the target image size
$destWidth = $img.Width;
@Serivy
Serivy / gulpfile.js
Created October 4, 2017 07:39
Quicker typescript watch.
// A experiment for quicker builds.
gulp.task('watch:typescript:quick', function () {
return gulp.watch(files.tsFiles).on("change", function(file) {
// Workaround to keep original folder structure
var currentDirectory = path.dirname(file.path);
var sourceDirectory = 'scripts';
var index = currentDirectory.indexOf(sourceDirectory);
var relativeDirectory = currentDirectory.slice(index + sourceDirectory.length + 1);
var outputDirectory = __dirname + "\\scripts\\output"
if (relativeDirectory) {
@Serivy
Serivy / Directory.Build.targets
Last active August 23, 2017 15:19
Use new Directory.Build.targets MSBuild 15 system.
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Import any parent target files. -->
<Import Condition="Exists('$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., $(MSBuildThisFile)))\$(MSBuildThisFile)')" Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., $(MSBuildThisFile)))\$(MSBuildThisFile)"/>
<!-- Include your logic here for the current level. -->
</Project>
@Serivy
Serivy / getfirstitem.targets
Created May 10, 2017 13:52
Gets the first item from an item group.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="GetFirstItem" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<Items ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<FirstItem ParameterType="System.String" Output="true" Required="false" />
</ParameterGroup>
<Task>
<Using Namespace="System.Linq"/>
<Code Type="Fragment" Language="cs">FirstItem = Items.First().ItemSpec;</Code>
@Serivy
Serivy / download.targets
Created September 13, 2016 05:03
MSBuild download task
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="DownloadFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<Url ParameterType="System.String" Required="true" />
<File ParameterType="System.String" Required="false" />
<OutputFolder ParameterType="System.String" Required="false" />
</ParameterGroup>
<Task>
<Using Namespace="System.Web"/>