Bringing run.exe into the repo and starting with the clean command
This commit is contained in:
parent
5ebc6a1ceb
commit
3a6e15309e
13 changed files with 234 additions and 6 deletions
1
BuildToolsCliVersion.txt
Normal file
1
BuildToolsCliVersion.txt
Normal file
|
@ -0,0 +1 @@
|
|||
1.0.0-preview2-002733
|
|
@ -1 +1 @@
|
|||
1.0.26-prerelease-00621-06
|
||||
1.0.26-prerelease-00621-06
|
|
@ -34,8 +34,8 @@
|
|||
|
||||
<Stage0Directory>$(RepoRoot)/.dotnet_stage0/$(Architecture)</Stage0Directory>
|
||||
<DotnetStage0>$(Stage0Directory)/dotnet$(ExeExtension)</DotnetStage0>
|
||||
|
||||
<DotnetCliBuildDirectory>$(RepoRoot)/build_projects/dotnet-cli-build</DotnetCliBuildDirectory>
|
||||
<PackagesDir>$(RepoRoot)/.nuget</PackagesDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -85,4 +85,6 @@
|
|||
<Import Project="build/Microsoft.DotNet.Cli.Package.targets" />
|
||||
<Import Project="build/Microsoft.DotNet.Cli.Test.targets" />
|
||||
<Import Project="build/Microsoft.DotNet.Cli.Publish.targets" />
|
||||
<Import Project="build/Microsoft.DotNet.Cli.Run.targets" />
|
||||
<Import Project="$(BuildToolsDir)/clean.targets" />
|
||||
</Project>
|
||||
|
|
12
build/Microsoft.DotNet.Cli.Run.targets
Normal file
12
build/Microsoft.DotNet.Cli.Run.targets
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<Target Name="CleanArtifacts" >
|
||||
<RemoveDir Directories="$(BaseOutputDirectory)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CleanRepo">
|
||||
<Exec Command="git clean -fdx" WorkingDirectory="$(RepoRoot)" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
12
clean.cmd
Normal file
12
clean.cmd
Normal file
|
@ -0,0 +1,12 @@
|
|||
@echo off
|
||||
|
||||
REM Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
REM Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
if "%~1"=="" (
|
||||
@call run.cmd clean -?
|
||||
@exit /b 1
|
||||
) else (
|
||||
@call run.cmd clean %*
|
||||
@exit /b %ERRORLEVEL%
|
||||
)
|
22
clean.sh
Executable file
22
clean.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
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 )"
|
||||
REPOROOT="$DIR"
|
||||
|
||||
if [ "$#" -lt 1 ]; then
|
||||
"$REPOROOT/run.sh" clean -?
|
||||
else
|
||||
"$REPOROOT/run.sh" clean "$@"
|
||||
fi
|
83
config.json
Normal file
83
config.json
Normal file
|
@ -0,0 +1,83 @@
|
|||
{
|
||||
"settings": {
|
||||
"Project": {
|
||||
"description": "Project where the commands are going to be applied.",
|
||||
"valueType": "passThrough",
|
||||
"values": [],
|
||||
"defaultValue": ""
|
||||
},
|
||||
"CleanArtifacts": {
|
||||
"description": "MsBuild target that deletes the artifacts output directory.",
|
||||
"valueType": "target",
|
||||
"values": [],
|
||||
"defaultValue": ""
|
||||
},
|
||||
"CleanPackages": {
|
||||
"description": "MsBuild target that deletes the repo-local nuget package directory.",
|
||||
"valueType": "target",
|
||||
"values": [],
|
||||
"defaultValue": ""
|
||||
},
|
||||
"CleanPackagesCache": {
|
||||
"description": "MsBuild target that deletes the user-local nuget package cache.",
|
||||
"valueType": "target",
|
||||
"values": [],
|
||||
"defaultValue": ""
|
||||
},
|
||||
"CleanRepo": {
|
||||
"description": "Cleans the entire repo of all non-git-added artifacts",
|
||||
"valueType": "target",
|
||||
"values": [],
|
||||
"defaultValue": ""
|
||||
},
|
||||
},
|
||||
"commands": {
|
||||
"clean":{
|
||||
"alias":{
|
||||
"o":{
|
||||
"description": "Deletes the artifacts directory.",
|
||||
"settings":{
|
||||
"CleanArtifacts": "default"
|
||||
}
|
||||
},
|
||||
"p":{
|
||||
"description": "Deletes the repo-local nuget package directory.",
|
||||
"settings":{
|
||||
"CleanPackages": "default"
|
||||
}
|
||||
},
|
||||
"u": {
|
||||
"description": "Deletes the user-local nuget package directory",
|
||||
"settings": {
|
||||
"CleanPackagesCache": "default"
|
||||
}
|
||||
},
|
||||
"a": {
|
||||
"description": "Deletes all repo content that is not git-added",
|
||||
"settings": {
|
||||
"CleanRepo" : "default"
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultValues":{
|
||||
"toolName": "msbuild",
|
||||
"settings": {
|
||||
"Project": "build.proj"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tools": {
|
||||
"msbuild": {
|
||||
"run": {
|
||||
"windows": "build_tools\\msbuild.cmd",
|
||||
"unix": "build_tools/msbuild.sh"
|
||||
},
|
||||
"valueTypes": {
|
||||
"property": "/p:{name}={value}",
|
||||
"target": "/t:{name}",
|
||||
"internal": "/{name}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -57,6 +57,25 @@ if (!(Test-Path "$BUILD_TOOLS_PACKAGE_PATH\init-tools.cmd"))
|
|||
exit 1
|
||||
}
|
||||
|
||||
# Bring down the CLI for build tools
|
||||
$DOTNET_PATH=$BUILD_TOOLS_PATH + "\dotnetcli"
|
||||
|
||||
Write-Host "Installing Build Tools CLI version..."
|
||||
if (!(Test-Path "$DOTNET_PATH"))
|
||||
{
|
||||
mkdir "$DOTNET_PATH"
|
||||
}
|
||||
|
||||
$DOTNET_VERSION = Get-Content "$RepoRoot\BuildToolsCliVersion.txt"
|
||||
$DOTNET_LOCAL_PATH=$DOTNET_PATH
|
||||
& "$RepoRoot\scripts\obtain\dotnet-install.ps1" -Channel "rel-1.0.0" -Version "$DOTNET_VERSION" -InstallDir "$DOTNET_LOCAL_PATH"
|
||||
|
||||
if (!(Test-Path "$DOTNET_LOCAL_PATH"))
|
||||
{
|
||||
Write-Host "Could not install Build Tools CLI version correctly"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Initialize build tools
|
||||
cmd /c "$BUILD_TOOLS_PACKAGE_PATH\init-tools.cmd $RepoRoot $env:DOTNET_INSTALL_DIR\dotnet.exe $BUILD_TOOLS_PATH" >> "$INIT_TOOLS_LOG"
|
||||
Write-Host "Done initializing tools."
|
||||
|
|
|
@ -17,12 +17,14 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
|||
$DIR/scripts/obtain/dotnet-install.sh --channel $CHANNEL --verbose
|
||||
|
||||
__init_tools_log=$DIR/init-tools.log
|
||||
__DOTNET_CMD=$DOTNET_INSTALL_DIR/dotnet
|
||||
__BUILD_TOOLS_CLI_VERSION=$(cat "$DIR/BuildToolsCliVersion.txt")
|
||||
__BUILD_TOOLS_DIR=$DIR/build_tools
|
||||
__BUILD_TOOLS_CLI_DIR=$__BUILD_TOOLS_DIR/dotnetcli/
|
||||
__BUILD_TOOLS_SOURCE=https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json
|
||||
__BUILD_TOOLS_PACKAGE_VERSION=$(cat $DIR/BuildToolsVersion.txt)
|
||||
__BUILD_TOOLS_PATH=$NUGET_PACKAGES/Microsoft.DotNet.BuildTools/$__BUILD_TOOLS_PACKAGE_VERSION/lib
|
||||
__BUILD_TOOLS_SEMAPHORE=$__BUILD_TOOLS_DIR/init-tools.completed
|
||||
__DOTNET_CMD=$DOTNET_INSTALL_DIR/dotnet
|
||||
__PROJECT_JSON_PATH=$__BUILD_TOOLS_DIR/$__BUILD_TOOLS_PACKAGE_VERSION
|
||||
__PROJECT_JSON_FILE=$__PROJECT_JSON_PATH/project.json
|
||||
__PROJECT_JSON_CONTENTS="{ \"dependencies\": { \"Microsoft.DotNet.BuildTools\": \"$__BUILD_TOOLS_PACKAGE_VERSION\" }, \"frameworks\": { \"netcoreapp1.0\": { } } }"
|
||||
|
@ -36,7 +38,11 @@ if [ ! -e "$__PROJECT_JSON_FILE" ]; then
|
|||
"$__DOTNET_CMD" restore "$__PROJECT_JSON_FILE" --packages "$NUGET_PACKAGES" --source "$__BUILD_TOOLS_SOURCE" >> "$__init_tools_log" 2>&1
|
||||
|
||||
if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then echo "ERROR: Could not restore build tools correctly. See '$__init_tools_log' for more details."; fi
|
||||
fi
|
||||
|
||||
if [ ! -d "$__BUILD_TOOLS_CLI_DIR" ]; then
|
||||
echo "Installing Build Tools CLI Version: $__BUILD_TOOLS_CLI_VERSION"
|
||||
"$DIR/scripts/obtain/dotnet-install.sh" --channel rel-1.0.0 --version "$__BUILD_TOOLS_CLI_VERSION" --install-dir "$__BUILD_TOOLS_CLI_DIR"
|
||||
fi
|
||||
|
||||
echo "Initializing build tools..."
|
||||
|
@ -46,3 +52,4 @@ if [ ! -e "$__PROJECT_JSON_FILE" ]; then
|
|||
else
|
||||
echo "Tools are already initialized"
|
||||
fi
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ param(
|
|||
# This is here just to eat away this parameter because CI still passes this in.
|
||||
[string]$Targets="Default",
|
||||
[switch]$NoPackage,
|
||||
[switch]$NoBuild,
|
||||
[switch]$Help,
|
||||
[Parameter(Position=0, ValueFromRemainingArguments=$true)]
|
||||
$ExtraParameters)
|
||||
|
@ -21,6 +22,7 @@ if($Help)
|
|||
Write-Host " -Configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug)"
|
||||
Write-Host " -Architecture <ARCHITECTURE> Build the specified architecture (x64 or x86 (supported only on Windows), default: x64)"
|
||||
Write-Host " -NoPackage Skip packaging targets"
|
||||
Write-Host " -NoBuild Skip building the product"
|
||||
Write-Host " -Help Display this help message"
|
||||
exit 0
|
||||
}
|
||||
|
@ -66,5 +68,13 @@ $env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
|
|||
# Disable first run since we want to control all package sources
|
||||
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||
|
||||
dotnet build3 build.proj /p:Architecture=$Architecture $ExtraParameters
|
||||
if($LASTEXITCODE -ne 0) { throw "Failed to build" }
|
||||
if ($NoBuild)
|
||||
{
|
||||
Write-Host "Not building due to --nobuild"
|
||||
Write-Host "Command that would be run: 'dotnet build3 build.proj /p:Architecture=$Architecture $ExtraParameters'"
|
||||
}
|
||||
else
|
||||
{
|
||||
dotnet build3 build.proj /p:Architecture=$Architecture $ExtraParameters
|
||||
if($LASTEXITCODE -ne 0) { throw "Failed to build" }
|
||||
}
|
||||
|
|
13
run-build.sh
13
run-build.sh
|
@ -19,6 +19,8 @@ OLDPATH="$PATH"
|
|||
ARCHITECTURE="x64"
|
||||
source "$REPOROOT/scripts/common/_prettyprint.sh"
|
||||
|
||||
BUILD=1
|
||||
|
||||
# Set nuget package cache under the repo
|
||||
export NUGET_PACKAGES="$REPOROOT/.nuget/packages"
|
||||
|
||||
|
@ -42,6 +44,9 @@ while [[ $# > 0 ]]; do
|
|||
export DOTNET_INSTALL_SKIP_PREREQS=1
|
||||
args=( "${args[@]/$1}" )
|
||||
;;
|
||||
--nobuild)
|
||||
BUILD=0
|
||||
;;
|
||||
--architecture)
|
||||
ARCHITECTURE=$2
|
||||
args=( "${args[@]/$1}" )
|
||||
|
@ -61,6 +66,7 @@ while [[ $# > 0 ]]; do
|
|||
echo " --configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug)"
|
||||
echo " --skip-prereqs Skip checks for pre-reqs in dotnet_install"
|
||||
echo " --nopackage Skip packaging targets"
|
||||
echo " --nobuild Skip building, showing the command that would be used to build"
|
||||
echo " --docker <IMAGENAME> Build in Docker using the Dockerfile located in scripts/docker/IMAGENAME"
|
||||
echo " --help Display this help message"
|
||||
exit 0
|
||||
|
@ -110,4 +116,9 @@ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
|||
|
||||
echo "${args[@]}"
|
||||
|
||||
dotnet build3 build.proj /p:Architecture=$ARCHITECTURE "${args[@]}"
|
||||
if [ $BUILD -eq 1 ]; then
|
||||
dotnet build3 build.proj /p:Architecture=$ARCHITECTURE "${args[@]}"
|
||||
else
|
||||
echo "Not building due to --nobuild"
|
||||
echo "Command that would be run is: 'dotnet build3 build.proj /p:Architecture=$ARCHITECTURE ${args[@]}'"
|
||||
fi
|
||||
|
|
25
run.cmd
Normal file
25
run.cmd
Normal file
|
@ -0,0 +1,25 @@
|
|||
@if "%_echo%" neq "on" echo off
|
||||
setlocal
|
||||
|
||||
if not defined VisualStudioVersion (
|
||||
if defined VS140COMNTOOLS (
|
||||
call "%VS140COMNTOOLS%\VsDevCmd.bat"
|
||||
goto :Run
|
||||
)
|
||||
echo Error: Visual Studio 2015 required.
|
||||
echo Please see https://github.com/dotnet/cli/blob/rel/1.0.0/Documentation/developer-guide.md for build instructions.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:Run
|
||||
powershell -NoProfile -NoLogo -Command "%~dp0build.cmd -NoBuild; exit $LastExitCode;"
|
||||
set _toolRuntime=%~dp0build_tools
|
||||
set _dotnet=%_toolRuntime%\dotnetcli\dotnet.exe
|
||||
|
||||
echo Running: %_dotnet% %_toolRuntime%\run.exe %*
|
||||
call %_dotnet% %_toolRuntime%\run.exe %~dp0config.json %*
|
||||
if NOT [%ERRORLEVEL%]==[0] (
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
exit /b 0
|
24
run.sh
Executable file
24
run.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
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 )"
|
||||
REPOROOT="$DIR"
|
||||
|
||||
$DIR/build.sh "--nobuild"
|
||||
|
||||
__toolRuntime=$REPOROOT/build_tools
|
||||
__dotnet=$__toolRuntime/dotnetcli/dotnet
|
||||
|
||||
echo "Running: $__dotnet $__toolRuntime/run.exe $@"
|
||||
$__dotnet $__toolRuntime/run.exe $DIR/config.json "$@"
|
Loading…
Add table
Reference in a new issue