Skip to content

Commit

Permalink
merge my spike on compile/publish/run and switch from PS1 to C#
Browse files Browse the repository at this point in the history
  • Loading branch information
analogrelay committed Oct 6, 2015
2 parents 550dd7f + ab8986e commit 43873a3
Show file tree
Hide file tree
Showing 43 changed files with 4,298 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
*.vbproj text=auto
*.fsproj text=auto
*.dbproj text=auto
*.sln text=auto eol=crlf
*.sln text=auto eol=crlf
3 changes: 2 additions & 1 deletion NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="www.myget.org" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
<add key="AspNetCIDev" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
<add key="dotnet-core" value="https://www.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
44 changes: 44 additions & 0 deletions dotnet-cli.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{1F391100-F011-4630-8C25-D1A5355E4F19}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5AB144A3-3D0A-4DC7-9EE8-19FDD2DF8735}"
ProjectSection(SolutionItems) = preProject
dotnet-compile.cmd = dotnet-compile.cmd
dotnet-run.cmd = dotnet-run.cmd
global.json = global.json
NuGet.Config = NuGet.Config
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{47858134-8A8D-4D5C-ABD5-E6630A66DA05}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestApp", "test\TestApp\TestApp.xproj", "{58808BBC-371E-47D6-A3D0-4902145EDA4E}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "DotNet.Tools.DependencyResolver", "src\DotNet.Tools.DependencyResolver\DotNet.Tools.DependencyResolver.xproj", "{A5D41198-209A-461B-A191-F48B9DBECD67}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{58808BBC-371E-47D6-A3D0-4902145EDA4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{58808BBC-371E-47D6-A3D0-4902145EDA4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{58808BBC-371E-47D6-A3D0-4902145EDA4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{58808BBC-371E-47D6-A3D0-4902145EDA4E}.Release|Any CPU.Build.0 = Release|Any CPU
{A5D41198-209A-461B-A191-F48B9DBECD67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A5D41198-209A-461B-A191-F48B9DBECD67}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5D41198-209A-461B-A191-F48B9DBECD67}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5D41198-209A-461B-A191-F48B9DBECD67}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{58808BBC-371E-47D6-A3D0-4902145EDA4E} = {47858134-8A8D-4D5C-ABD5-E6630A66DA05}
{A5D41198-209A-461B-A191-F48B9DBECD67} = {1F391100-F011-4630-8C25-D1A5355E4F19}
EndGlobalSection
EndGlobal
30 changes: 30 additions & 0 deletions dotnet-compile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$OutputName = Split-Path -Leaf (Get-Location)
$OutputPath = Join-Path (Get-Location) "bin"

if(!(Test-Path $OutputPath)) {
mkdir $OutputPath | Out-Null
}
$OutputPath = (Convert-Path $OutputPath)


# Resolve compilation dependencies
Write-Host "Resolving dependencies..."
$refs = dnx -p "$PSScriptRoot\src\DotNet.Tools.DependencyResolver" run --packages "$env:USERPROFILE\.dnx\packages" --target "DNXCore,Version=v5.0" --assets compile

# Resolve source files
Write-Host "Finding source files..."
$srcs = dnx -p "$PSScriptRoot\src\DotNet.Tools.SourceResolver" run

# Build csc response file
$resp = @($refs | foreach { "/r:$_" })
$resp += @($srcs | foreach { $_ })
$resp += @(
"/out:$OutputPath\$OutputName.dll"
"/nostdlib"
)

Write-Host "Compiling..."
$resp > "$OutputPath\csc.rsp"
csc "@$OutputPath\csc.rsp"

Write-Host " $OutputName -> $OutputPath\$OutputName.dll"
31 changes: 31 additions & 0 deletions dotnet-publish.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$OutputName = Split-Path -Leaf (Get-Location)
$OutputPath = Join-Path (Join-Path (Get-Location) "bin") "publish"

& $PSScriptRoot\dotnet-compile.ps1

if(Test-Path $OutputPath) {
del -Recurse -Force $OutputPath
}
mkdir $OutputPath | Out-Null
$OutputPath = (Convert-Path $OutputPath)

# Resolve runtime and native dependencies
Write-Host "Resolving dependencies..."
$refs = dnx -p "$PSScriptRoot\src\DotNet.Tools.DependencyResolver" run --packages "$env:USERPROFILE\.dnx\packages" --target "DNXCore,Version=v5.0/win7-x64" --assets runtime --assets native

# Copy everything to one directory
$refs | foreach {
Write-Host "Publishing $_ ..."
cp $_ $OutputPath
}

$ProjectBinary = (Join-Path (Get-Location) "bin\$OutputName.dll")
Write-Host "Publishing $ProjectBinary ..."
cp $ProjectBinary $OutputPath

# CoreConsole should have come along for the ride
$CoreConsolePath = Join-Path $OutputPath "CoreConsole.exe"
if(!(Test-Path $CoreConsolePath)) {
throw "Unable to locate CoreConsole.exe. You must have a dependency on Microsoft.NETCore.ConsoleHost (for now ;))"
}
mv $CoreConsolePath (Join-Path $OutputPath "$OutputName.exe")
18 changes: 17 additions & 1 deletion scripts/dotnet-compile
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
exec "dnu" "build" "$@"
#!/usr/bin/env bash

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

# work around restore timeouts on Mono
[ -z "$MONO_THREADS_PER_CPU" ] && export MONO_THREADS_PER_CPU=50

# Makes development easier
export PATH=$PATH:$DIR

exec "dnx" -p "$DIR/../src/Microsoft.DotNet.Tools.Compiler" run "$@"
7 changes: 5 additions & 2 deletions scripts/dotnet-compile.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
SETLOCAL
SET ERRORLEVEL=

dnu build %*
REM makes testing easier for now
set PATH=%PATH%;%~dp0

dnx %DOTNET_OPTIONS% -p %~dp0..\src\Microsoft.DotNet.Tools.Compiler run %*

exit /b %ERRORLEVEL%
ENDLOCAL
ENDLOCAL
17 changes: 17 additions & 0 deletions scripts/dotnet-publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

# work around restore timeouts on Mono
[ -z "$MONO_THREADS_PER_CPU" ] && export MONO_THREADS_PER_CPU=50

# Makes development easier
export PATH=$PATH:$DIR

exec "dnx" -p "$DIR/../src/Microsoft.DotNet.Tools.Publish" run "$@"
11 changes: 11 additions & 0 deletions scripts/dotnet-publish.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@Echo OFF
SETLOCAL
SET ERRORLEVEL=

REM makes testing easier for now
set PATH=%PATH%;%~dp0

dnx %DOTNET_OPTIONS% -p %~dp0..\src\Microsoft.DotNet.Tools.Publish run %*

exit /b %ERRORLEVEL%
ENDLOCAL
17 changes: 17 additions & 0 deletions scripts/dotnet-resolve-references
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

# work around restore timeouts on Mono
[ -z "$MONO_THREADS_PER_CPU" ] && export MONO_THREADS_PER_CPU=50

# Makes development easier
export PATH=$PATH:$DIR

exec "dnx" -p "$DIR/../src/Microsoft.DotNet.Tools.DependencyResolver" run "$@"
11 changes: 11 additions & 0 deletions scripts/dotnet-resolve-references.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@Echo OFF
SETLOCAL
SET ERRORLEVEL=

REM makes testing easier for now
set PATH=%PATH%;%~dp0

dnx %DOTNET_OPTIONS% -p %~dp0..\src\Microsoft.DotNet.Tools.DependencyResolver run %*

exit /b %ERRORLEVEL%
ENDLOCAL
17 changes: 17 additions & 0 deletions scripts/dotnet-resolve-sources
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

# work around restore timeouts on Mono
[ -z "$MONO_THREADS_PER_CPU" ] && export MONO_THREADS_PER_CPU=50

# Makes development easier
export PATH=$PATH:$DIR

exec "dnx" -p "$DIR/../src/Microsoft.DotNet.Tools.SourceResolver" run "$@"
11 changes: 11 additions & 0 deletions scripts/dotnet-resolve-sources.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@Echo OFF
SETLOCAL
SET ERRORLEVEL=

REM makes testing easier for now
set PATH=%PATH%;%~dp0

dnx %DOTNET_OPTIONS% -p %~dp0..\src\Microsoft.DotNet.Tools.SourceResolver run %*

exit /b %ERRORLEVEL%
ENDLOCAL
17 changes: 17 additions & 0 deletions scripts/dotnet-run
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

# work around restore timeouts on Mono
[ -z "$MONO_THREADS_PER_CPU" ] && export MONO_THREADS_PER_CPU=50

# Makes development easier
export PATH=$PATH:$DIR

exec "dnx" -p "$DIR/../src/Microsoft.DotNet.Tools.Run" run "$@"
11 changes: 11 additions & 0 deletions scripts/dotnet-run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@Echo OFF
SETLOCAL
SET ERRORLEVEL=

REM makes testing easier for now
set PATH=%PATH%;%~dp0

dnx %DOTNET_OPTIONS% -p %~dp0..\src\Microsoft.DotNet.Tools.Run run %*

exit /b %ERRORLEVEL%
ENDLOCAL
Loading

0 comments on commit 43873a3

Please sign in to comment.