Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try 2 bootstrapping swagger to .net sdk tools #5334

Merged
merged 4 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ Icon
# Thumbnails
._*

# Ignore repo files
/scripts/stostools/restoredPackages
/scripts/stostools/restoredpackages

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
Expand Down
132 changes: 132 additions & 0 deletions scripts/stostools/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CurrentDir>$(MSBuildThisFileDirectory)</CurrentDir>
<RepoRootRelPath>.\</RepoRootRelPath>
<RepoRootAbspath>$([System.IO.Path]::GetFullPath($(CurrentDir)).Trim('\'))</RepoRootAbspath>
</PropertyGroup>
<PropertyGroup>
<RepoRoot>$(RepoRootAbspath)</RepoRoot>
<RepoSrcDir>$(RepoRoot)\src</RepoSrcDir>
<RepoToolsDir>$(RepoRoot)\tools</RepoToolsDir>
<RepoEngDir>$(RepoRoot)\eng</RepoEngDir>
<RepoNugetFeedDir>$(RepoToolsDir)\LocalNugetFeed</RepoNugetFeedDir>
<RepoDeveloperDir>$(RepoEngDir)\alias</RepoDeveloperDir>
<RepoNugetDir>$(RepoToolsDir)\NugetExe</RepoNugetDir>
<NugPkgSrcDir>$(RepoSrcDir)\NugetToolsPackage</NugPkgSrcDir>
<RepoNugetRestoreDir>$(RepoRoot)\restoredPackages</RepoNugetRestoreDir>
</PropertyGroup>

<PropertyGroup>
<DevMode Condition=" '$(DevMode)' == '' ">false</DevMode>
</PropertyGroup>

<PropertyGroup Label="CI paths">
<RepoCISrcDir>$(RepoSrcDir)\CI</RepoCISrcDir>
<RepoCICommonSrcDir>$(RepoCISrcDir)\CI.Common</RepoCICommonSrcDir>
<RepoCIBuildTaskDir>$(RepoCISrcDir)\CI.BuildTasks</RepoCIBuildTaskDir>
<CINugPkgSrcDir>$(NugPkgSrcDir)\CI.Tools.Package</CINugPkgSrcDir>
<CIBuildOutputDir>$(CINugPkgSrcDir)\build\tasks</CIBuildOutputDir>
<CINugPkgPublish_NetStd20Dir>$(CIBuildOutputDir)\netstandard2.0</CINugPkgPublish_NetStd20Dir>
</PropertyGroup>

<PropertyGroup Label="SToS paths">
<RepoSToSSrcDir>$(RepoSrcDir)\SwaggerToSdk</RepoSToSSrcDir>
<RepoSToSCommonSrcDir>$(RepoSToSSrcDir)\Common\SToS.Common</RepoSToSCommonSrcDir>
<RepoSToSBuildTaskSrcDir>$(RepoSToSSrcDir)\BuildTasks\SToS.BuildTasks</RepoSToSBuildTaskSrcDir>
<SToSNugPkgSrcRootDir>$(NugPkgSrcDir)\SwaggerToSdk.Tools.Package</SToSNugPkgSrcRootDir>
<SToSNugPkgSrcDir>$(SToSNugPkgSrcRootDir)\build</SToSNugPkgSrcDir>
<SToSNugPkgSdkDir>$(SToSNugPkgSrcDir)\Sdk</SToSNugPkgSdkDir>
<SToSBuildOutputDir>$(SToSNugPkgSrcDir)\tasks</SToSBuildOutputDir>
<SToSNugPkgPublish_NetStd20Dir>$(SToSBuildOutputDir)\netstandard2.0</SToSNugPkgPublish_NetStd20Dir>
<SToSNugPkgPublish_Net461Dir>$(SToSBuildOutputDir)\net461</SToSNugPkgPublish_Net461Dir>
</PropertyGroup>

<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">AnyCPU</Platform>
</PropertyGroup>

<!--
MSBuildRuntimeType can have 'Core', 'Full' and 'Mono' as three possible values
https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-reserved-and-well-known-properties?view=vs-2017
-->
<PropertyGroup>
<DotNetRuntimeContext>$(MSBuildRuntimeType)</DotNetRuntimeContext>
<FxVersionTasksToUse Condition=" '$(DotNetRuntimeContext)' == 'Core' ">netstandard2.0</FxVersionTasksToUse>
<FxVersionTasksToUse Condition=" '$(FxVersionTasksToUse)' == '' AND '$(DotNetRuntimeContext)' != 'Core' ">net461</FxVersionTasksToUse>
</PropertyGroup>
<PropertyGroup Condition="'$(MSBuildRuntimeType)' == 'Core'">
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>

<ItemGroup>
<TestDataProjects Include="$(RepoCISrcDir)\CI.BuildTasks\Tests\TestDataProject\*.csproj" />

<CITestProjects Include="$(RepoCISrcDir)\CI.BuildTasks\Tests\**\*.csproj" Exclude="@(TestDataProjects)" />
<SToSTestProjects Include="$(RepoSToSSrcDir)\BuildTasks\Tests\*.csproj;$(RepoSToSSrcDir)\Common\Tests\*.csproj" />
<SToSProjects Include="$(RepoSToSBuildTaskSrcDir)\*.csproj;$(RepoSToSCommonSrcDir)\*.csproj" />
<SToSNugPkgProjects Include="$(SToSNugPkgSrcDir)\*.csproj" />

<NugetPkgProjects Include="@(SToSNugPkgProjects)" />
<ProjectsToBuild Include="@(SToSProjects);@(SToSTestProjects)" />
<ProjectsToPublish Include="@(SToSProjects)" />
</ItemGroup>

<!--
Detect CI env using available env variables
https://<Jenkins server url>/systemInfo
https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
-->
<PropertyGroup>
<IsJenkinsCI Condition=" '$(JENKINS_HOME)' != '' ">true</IsJenkinsCI>
<IsTravisCI Condition=" '$(Travis)' != '' ">true</IsTravisCI>
<IsCIEnvironment Condition=" '$(IsJenkinsCI)' == 'true' OR '$(IsTravisCI)' == 'true' ">true</IsCIEnvironment>
<IsCIEnvironment Condition=" '$(IsCIEnvironment)' == '' ">false</IsCIEnvironment>
</PropertyGroup>

<!--
===========================================================================================
Developer Settings
On non-windows machine, user can setup an environment variable that will point to their developer settings props file.
The name of the file should be named as currentUser.props (case sensitive)
On windows machine, if the environment variable is not set, we will attempt to use the windows current user env. variable

Env. variables
LocalDevUserBootstrapDirPath == will point to the directory from where currentuser.props should be imported
DevMode == flags if you want to be in dev mode, which is basically avoids restoring nuget package and directly loads the build environment

Default file that will be loaded == currentUser.props (if available)
===========================================================================================
-->
<PropertyGroup Condition=" '$(DevMode)' == 'true' ">
<DefaultCurrentUserPropsFileName>currentUser.props</DefaultCurrentUserPropsFileName>
<DeveloperCurrentUserPropFilePath>$(LocalDevUserBootstrapDirPath)\$(DefaultCurrentUserPropsFileName)</DeveloperCurrentUserPropFilePath>
<DeveloperCurrentUserPropFilePath Condition=" !Exists($(DeveloperCurrentUserPropFilePath))">$(RepoDeveloperDir)\$(UserName)\$(DefaultCurrentUserPropsFileName)</DeveloperCurrentUserPropFilePath>
</PropertyGroup>

<Import Condition="Exists($(DeveloperCurrentUserPropFilePath)) AND '$(IsCIEnvironment)' != 'true' AND '$(DevMode)' == 'true' " Project="$(DeveloperCurrentUserPropFilePath)" />
<PropertyGroup Condition=" '$(IsCIEnvironment)' != 'true' AND '$(DevMode)' == 'true' ">
<LocalDevUser Condition=" '$(LocalDevUser)' == '' ">$(UserName)</LocalDevUser>
<DefaultCurrentuserTargetsFileName>$(LocalDevUser).bootStrap.targets</DefaultCurrentuserTargetsFileName>
<DeveloperCurrentUserPropFilePath>$(RepoDeveloperDir)\$(LocalDevUser)\$(DefaultCurrentUserPropsFileName)</DeveloperCurrentUserPropFilePath>
</PropertyGroup>

<PropertyGroup Condition=" '$(IsCIEnvironment)' != 'true' AND '$(DevMode)' == 'true' ">
<LocalDevUserTargetsDir Condition="Exists('$(RepoDeveloperDir)\$(LocalDevUser)')">$(RepoDeveloperDir)\$(LocalDevUser)</LocalDevUserTargetsDir>
<LocalDevUserBootstrapPropsFile>$(LocalDevUserTargetsDir)\$(DefaultCurrentuserTargetsFileName)</LocalDevUserBootstrapPropsFile>
<CurrentUserPropsFilePath>$(LocalDevUserBootstrapDirPath)\currentUser.props</CurrentUserPropsFilePath>

<DevMode_SDK_SToSPropsFile>$(SToSNugPkgSdkDir)\SToS.props</DevMode_SDK_SToSPropsFile>
</PropertyGroup>
<Import Condition="Exists($(LocalDevUserBootstrapPropsFile)) AND '$(IsCIEnvironment)' != 'true' AND '$(DevMode)' == 'true' " Project="$(LocalDevUserBootstrapPropsFile)" />

<!-- DO NOT MAKE ANY CHANGES BELOW -->
<PropertyGroup>
<IsJenkinsCI Condition=" '$(JENKINS_HOME)' != '' ">true</IsJenkinsCI>
<IsTravisCI Condition=" '$(Travis)' != '' ">true</IsTravisCI>
<IsCIEnvironment Condition=" '$(IsJenkinsCI)' == 'true' OR '$(IsTravisCI)' == 'true' ">true</IsCIEnvironment>
<IsCIEnvironment Condition=" '$(IsCIEnvironment)' == '' ">false</IsCIEnvironment>
<DevMode Condition=" '$(IsCIEnvironment)' == 'true' ">false</DevMode>
</PropertyGroup>
</Project>
31 changes: 31 additions & 0 deletions scripts/stostools/LaunchSToS.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@echo OFF

set StartupProj=%1
set PrNumber=%2
set LastGithubCommitId=%3
set GitHubUrl=%4
set TriggerComment=%5
set DebugMode=%6
set LogVerbosity=%7

if "%VSWHERE%"=="" set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"

for /f "usebackq tokens=*" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set InstallDir=%%i
)

CALL "%InstallDir%\Common7\Tools\VsDevCmd.bat"

echo StartupProj: %StartupProj%
echo Pr#: %PrNumber%
echo Last Commit Id: %LastGithubCommitId%
echo GitHub Url: %GitHubUrl%
echo Trigger Comment: %TriggerComment%
echo DebugMode: %DebugMode%
echo Log Verbosity: %LogVerbosity%

dotnet msbuild %startupProj% /t:StartNetSdkCodeGeneration /v:%LogVerbosity% /p:githubprnumber=%PrNumber% /p:githubcommitid=%LastGithubCommitId% /p:giturl=%GitHubUrl% /p:DebugMode=%DebugMode% /p:triggercomment=%TriggerComment%

REM dotnet msbuild stos.proj /t:StartNetSdkCodeGeneration /v:N /p:githubprnumber=63 /p:githubcommitid=b5ee45302838515adc14857ed45c44ed99a1e517 /p:giturl=https://github.com/Azure/AzSwaggerSpecsTestClone /p:DebugMode=false /p:triggercomment=startbuild
REM LaunchSToS.bat stos.proj 63 b5ee45302838515adc14857ed45c44ed99a1e517 https://github.com/Azure/AzSwaggerSpecsTestClone startbuild false D
REM stostools\LaunchSToS.bat SToS.proj %ghprbPullId% %ghprbActualCommit% %GIT_URL% %ghprbCommentBody% false n
21 changes: 21 additions & 0 deletions scripts/stostools/nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="NugetOfficialV3" value="https://api.nuget.org/v3/index.json" />
<add key="Local" value="tools/LocalNugetFeed" />
<add key="stosprodfeed" value="\\aaptfile01\ADXSDK\NetSDK\SToS\Prod" />
</packageSources>

<config>
<add key="globalPackagesFolder" value=".\restoredPackages\" />
<add key="RestorePackagesPath" value=".\restoredPackages\" />
</config>

<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />

<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
</configuration>
43 changes: 43 additions & 0 deletions scripts/stostools/stos.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Directory.Build.props" />
<Import Condition=" '$(DevMode)' != 'true' " Project="SToS.props" Sdk="Microsoft.Internal.SwaggerToSdk.Tools" Version="0.9.0" />
<Import Condition=" '$(DevMode)' == 'true' AND Exists('$(DevMode_SDK_SToSPropsFile)') " Project="$(DevMode_SDK_SToSPropsFile)" />

<PropertyGroup>
<DotNetRuntimeContext>$(MSBuildRuntimeType)</DotNetRuntimeContext>
<FxVersionTasksToUse Condition=" '$(DotNetRuntimeContext)' == 'Core' ">netstandard2.0</FxVersionTasksToUse>
<FxVersionTasksToUse Condition=" '$(FxVersionTasksToUse)' == '' AND '$(DotNetRuntimeContext)' == 'Full' ">net461</FxVersionTasksToUse>
</PropertyGroup>
<Target Name="Fn">
<Message Text="FxVersionTasksToUse is ......... $(FxVersionTasksToUse)" />
</Target>

<Target Name="StartNetSdkCodeGeneration">
<Message Text="Commencing code generation" Importance = "High"/>
<StartNetSdkCodeGeneration
GitHubPRNumber="$(githubprnumber)"
GitHubCommitId="$(githubcommitid)"
GithubRepositoryUrl="$(giturl)"
TriggerComment="$(triggercomment)"
DebugMode="$(debugmode)"
>
<Output TaskParameter="NetSdkPRMetadataRowId" PropertyName="NetSdkPRMetadataRowId" />
</StartNetSdkCodeGeneration>
</Target>

<Target Name="HandleClosedOrMergedRestApiPrs">
<Message Text="Handling closed or merged PRs" Importance = "High"/>
<HandleClosedOrMergedRestApiPrs
RepositoryUrl="$(RepositoryUrl)"
>
</HandleClosedOrMergedRestApiPrs>
</Target>

<Target Name="KV">
<GetKVSecrets>
<Output TaskParameter="Email" PropertyName="EmailAddress" />
</GetKVSecrets>

<Message Text="Email is $(EmailAddress)" />
</Target>
</Project>