提交 6e3cc248 编写于 作者: J Jared Parsons 提交者: Jared Parsons

Centralize tool version numbers

This lets us avoid hard coding in version numbers for the core tools
we use in our build.
上级 886b8703
......@@ -65,3 +65,12 @@ The general structure of this file is:
- Import all of the external targets.
- PropertyGroup to adjust properties set by the external projects.
- Custom Targets for our build.
### Version property files
There are a number props files that just control version numbers:
- Packages.props: version numbers for all of the NuGet packages we use. Versions here presumably will change as new packages are available.
- FixedPackages.props: similar to Packages.props but for packages that should never change versions. They are fixed and do not change when new packages are available. Typically used for producing SDKs for older VS / .NET versions.
- Tools.props: version numbers for non-Nuget assets.
......@@ -174,7 +174,11 @@
<Import Project="$(NuGetPackageRoot)\Microsoft.VSSDK.BuildTools\$(VisualStudioBuildToolsVersion)\build\Microsoft.VsSDK.BuildTools.props" />
</ImportGroup>
<!-- PROTOTYPE undo the OS check -->
<!--
Temporarirly disable Toolset builds on Unix
https://github.com/dotnet/roslyn/issues/21725
-->
<Import Project="$(ToolsetCompilerPropsFilePath)" Condition="Exists('$(ToolsetCompilerPropsFilePath)') AND '$(BootstrapBuildPath)' == '' AND '$(OS)' == 'Windows_NT'" />
<!--
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<dotnetSdkVersion>2.0.0-preview3-006923<dotnetSdkVersion>
<nugetExeVersion>4.1.0<nugetExeVersion>
</PropertyGroup>
</Project>
......@@ -110,7 +110,7 @@ function Exec-Script([string]$script, [string]$scriptArgs = "") {
# Ensure that NuGet is installed and return the path to the
# executable to use.
function Ensure-NuGet() {
$nugetVersion = "4.1.0"
$nugetVersion = Get-ToolVersion "nugetExe"
$toolsDir = Join-Path $binariesDir "Tools"
Create-Directory $toolsDir
......@@ -136,7 +136,7 @@ function Ensure-NuGet() {
# Ensure the proper SDK in installed in our %PATH%. This is how MSBuild locates the
# SDK.
function Ensure-SdkInPathAndData() {
$sdkVersion = "2.0.0-preview3-006923"
$sdkVersion = Get-ToolVersion "dotnetSdk"
# Get the path to dotnet.exe. This is the first path on %PATH% that contains the
# dotnet.exe instance. Many SDK tools use this to locate items like the SDK.
......@@ -245,13 +245,11 @@ function Create-Directory([string]$dir) {
New-Item $dir -ItemType Directory -ErrorAction SilentlyContinue | Out-Null
}
# Return the version of the NuGet package as used in this repo
function Get-PackageVersion([string]$name) {
function Get-VersionCore([string]$name, [string]$versionFile) {
$name = $name.Replace(".", "")
$name = $name.Replace("-", "")
$deps = Join-Path $repoDir "build\Targets\Packages.props"
$nodeName = "$($name)Version"
$x = [xml](Get-Content -raw $deps)
$x = [xml](Get-Content -raw $versionFile)
$node = $x.Project.PropertyGroup.FirstChild
while ($node -ne $null) {
if ($node.Name -eq $nodeName) {
......@@ -260,7 +258,18 @@ function Get-PackageVersion([string]$name) {
$node = $node.NextSibling
}
throw "Cannot find package $name in Packages.props"
throw "Cannot find package $name in $versionFile"
}
# Return the version of the NuGet package as used in this repo
function Get-PackageVersion([string]$name) {
return Get-VersionCore $name (Join-Path $repoDir "build\Targets\Packages.props")
}
# Return the version of the specified tool
function Get-ToolVersion([string]$name) {
return Get-VersionCore $name (Join-Path $repoDir "build\Targets\Tools.props")
}
# Locate the directory where our NuGet packages will be deployed. Needs to be kept in sync
......
#!/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
set -u
get_repo_dir()
{
local d=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
pushd $d > /dev/null
cd ..
cd ..
local repoDir=$(pwd)
popd > /dev/null
echo $repoDir
}
# This function will give you the current version number for the specified string in the
# specified version file.
get_version_core()
{
local name=${1/./}
local name=${name/-/}
local version=$(awk -F'[<>]' "/<${name}Version>/{print \$3}" $2)
echo $version
}
# This function will give you the current version number for a given nuget package
# based on the contents of Packages.props.
#
# Provide the package name in the format shown in the nuget gallery
# get_package_version dotnet-xunit
# get_package_version System.Console
get_package_version()
{
local repoDir=$(get_repo_dir)
local version=$(get_version_core $1 ${repoDir}/build/Targets/Packages.props)
echo $version
}
get_tool_version()
{
local repoDir=$(get_repo_dir)
local version=$(get_version_core $1 ${repoDir}/build/Targets/Tools.props)
echo $version
}
......@@ -21,8 +21,10 @@ fi
# This is a function to keep variable assignments out of the parent script (that is sourcing this file)
install_dotnet () {
# Download and install `dotnet` locally
local DOTNET_VERSION=2.0.0-preview3-006923
local THIS_DIR=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source ${THIS_DIR}/build-utils.sh
local DOTNET_VERSION=$(get_tool_version dotnetSdk)
local DOTNET_PATH=${THIS_DIR}/../../Binaries/dotnet-cli
if [[ ! -x "${DOTNET_PATH}/dotnet" ]]
......
......@@ -5,23 +5,11 @@
set -e
set -u
# This function will give you the current version number for a given nuget package
# based on the contents of Packages.props.
#
# Provide the package name in the format shown in the nuget gallery
# get_package_version dotnet-xunit
# get_package_version System.Console
get_package_version()
{
local name=${1/./}
local name=${name/-/}
local version=$(awk -F'[<>]' "/<${name}Version>/{print \$3}" ${SRC_PATH}/build/Targets/Packages.props)
echo $version
}
BUILD_CONFIGURATION=${1:-Debug}
THIS_DIR=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source ${THIS_DIR}/build-utils.sh
BINARIES_PATH=${THIS_DIR}/../../Binaries
SRC_PATH=${THIS_DIR}/../..
UNITTEST_DIR=${BINARIES_PATH}/${BUILD_CONFIGURATION}/UnitTests
......@@ -38,7 +26,6 @@ echo Using $XUNIT_CONSOLE
NEED_PUBLISH=(
'src\Compilers\CSharp\Test\Symbol\CSharpCompilerSymbolTest.csproj'
)
BUILD_ARGS="--no-restore -c ${BUILD_CONFIGURATION} -consoleloggerparameters:Verbosity=minimal;summary -p:RuntimeIdentifier=${RUNTIME_ID} -p:TargetFramework=${TARGET_FRAMEWORK}"
for p in $NEED_PUBLISH
do
echo Publishing ${p}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册