Skip to content

Commit

Permalink
Add sourcelink support (#3)
Browse files Browse the repository at this point in the history
* Add sourcelink

* Update appveyor artifact path

* Improve publish script
  • Loading branch information
Alxandr authored Aug 4, 2017
1 parent 8c223f9 commit 64a9447
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 19 deletions.
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
init:
- git config --global core.autocrlf true
- git config --global core.autocrlf input

clone_depth: 1
test: off
Expand All @@ -20,10 +20,10 @@ before_build:

build_script:
- ps: .\build.ps1
- ps: .\publish.ps1
- ps: .\script\publish.ps1

artifacts:
- path: src/*/bin/**/*.nupkg
- path: bin/*.nupkg

deploy:
- provider: Environment
Expand Down
8 changes: 8 additions & 0 deletions build/build.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.6;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<DotNetCliToolReference Include="dotnet-sourcelink" Version="[2.1.0]" />
</ItemGroup>
</Project>
14 changes: 14 additions & 0 deletions build/common.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project>
<PropertyGroup>

<Authors>Aleksander Heintz</Authors>
<PackageLicenseUrl>https://opensource.org/licenses/MIT</PackageLicenseUrl>
<!--<PackageIconUrl>https://ctaggart.github.io/SourceLink/SourceLink128.jpg</PackageIconUrl>-->
<PackageProjectUrl>/~https://github.com/YoloDev/YoloDev.AspNetCore.Assets</PackageProjectUrl>
<PackageTags>aspnet mvc webpack assets</PackageTags>
<Description>Deal with assets that have generated names for dist.</Description>

<DebugType>embedded</DebugType>

</PropertyGroup>
</Project>
5 changes: 5 additions & 0 deletions build/sourcelink.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<ItemGroup>
<PackageReference Include="SourceLink.Create.CommandLine" Version="[2.1.0]" PrivateAssets="all" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Shared.proj → build/version.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<GitVersionExec><![CDATA[
set PATH=/usr/bin;%PATH%
sh -c "bash '$(MSBuildThisFileDirectory)script/git-version.sh' get"
sh -c "bash '$(MSBuildThisFileDirectory)/../script/git-version.sh' get"
]]></GitVersionExec>
</PropertyGroup>

Expand Down
14 changes: 0 additions & 14 deletions publish.ps1

This file was deleted.

37 changes: 37 additions & 0 deletions script/publish.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# create this function in the calling script
function Get-ScriptDirectory { Split-Path $MyInvocation.ScriptName }

function __exec($cmd) {
$cmdName = [IO.Path]::GetFileName($cmd)
Write-Host -ForegroundColor Cyan "> $cmdName $args"
$originalErrorPref = $ErrorActionPreference
$ErrorActionPreference = 'Continue'
& $cmd @args
$exitCode = $LASTEXITCODE
$ErrorActionPreference = $originalErrorPref
if ($exitCode -ne 0) {
throw "'$cmdName $args' failed with exit code: $exitCode"
}
}

$bindir = Join-Path (Get-ScriptDirectory) "../bin"
if (Test-Path $bindir) {
Remove-Item -Recurse -Force $bindir
}

$projects = Get-ChildItem src/**/*.csproj
foreach ($project in $projects) {
__exec dotnet pack "$project" "-c" "release" "-o" "$bindir" "/v:m" "/p:ci=true"
}

$nupkgs = Get-ChildItem bin/*.nupkg
Push-Location "build"
try {
__exec dotnet restore
foreach ($nupkg in $nupkgs) {
__exec dotnet sourcelink test $nupkg
}
}
finally {
Pop-Location
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../../Shared.proj" />
<Import Project="../../build/common.props" />
<Import Project="../../build/sourcelink.props" />

<PropertyGroup>
<TargetFrameworks>netstandard1.6;net461</TargetFrameworks>
</PropertyGroup>
Expand All @@ -12,4 +14,6 @@
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="1.1.3" />
</ItemGroup>

<Import Project="../../build/version.targets" />
</Project>

0 comments on commit 64a9447

Please sign in to comment.