Skip to content

Commit

Permalink
Adding a way to publish single nuget package when a scope is provided…
Browse files Browse the repository at this point in the history
…. This change will also allow publishing multiple packages from the same scope (only NetCore projects are supported as this stage) Adding test collateral and tests to test publishing one project
  • Loading branch information
shahabhijeet committed Dec 14, 2016
1 parent 403d221 commit e476727
Show file tree
Hide file tree
Showing 31 changed files with 723 additions and 16 deletions.
19 changes: 11 additions & 8 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@
<FxTargetList Condition=" '$(Scope)' == 'authentication' ">net45</FxTargetList>
<ZipExeFolder>$(LibraryToolsFolder)\7-Zip</ZipExeFolder>
<ZipExe>$(ZipExeFolder)\7z.exe</ZipExe>
<NuGetCommand>&quot;$(LibraryToolsFolder)\nuget.exe&quot;</NuGetCommand>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="'$(PublishTestProjects)' == 'false' Or '$(PublishTestProjects)' == ''">
<LibrariesToBuild Include="$(LibrarySourceFolder)\$(Scope)\*.sln" Condition=" '$(Scope)' != 'all' " />
<LibrariesToBuild Include="$(LibrarySourceFolder)\**\*.sln" Condition=" '$(Scope)' == 'all' " />
<LibraryFxTargetList Include="$(FxTargetList)" />
Expand All @@ -72,10 +73,8 @@
<ClientRuntimeTests Include="$(LibrarySourceFolder)\ClientRuntime\*.Tests\*.xproj" />
</ItemGroup>

<PropertyGroup>
<NuGetCommand>&quot;$(LibraryToolsFolder)\nuget.exe&quot;</NuGetCommand>
</PropertyGroup>

<Import Condition="$(PublishTestProjects) == 'true'" Project="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks\Build.Tasks.Tests\PublishNugetPackageTests.proj" />

<UsingTask TaskName="ValidateStrongNameSignatureTask" AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" />
<UsingTask TaskName="FilterOutAutoRestLibraries" AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" />
<UsingTask TaskName="BuildProjectTemplatesTask" AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" />
Expand Down Expand Up @@ -122,7 +121,7 @@
<Import Condition=" $(OnPremiseBuild) " Project="$(CIToolsPath)\Microsoft.WindowsAzure.Build.OnPremise.msbuild" />

<Target Name="PrepareForAutoRestLibraries">
<FilterOutAutoRestLibraries AllLibraries="@(LibrariesToBuild)" AutoRestMark="AutoRestProjects">
<FilterOutAutoRestLibraries AllLibraries="@(LibrariesToBuild)" AutoRestMark="AutoRestProjects" NugetPackagesToPublish="$(PackageName)">
<Output TaskParameter="Non_NetCore_AutoRestLibraries" ItemName="Non_NetCore_AutoRestLibraries" />
<Output TaskParameter="NetCore_AutoRestLibraries" ItemName="NetCore_AutoRestLibraries" />
</FilterOutAutoRestLibraries>
Expand All @@ -131,16 +130,20 @@

<!--Do not build old libraries except Authentication, which Azure PowerShell still uses-->
<ItemGroup>
<NonAutoRestLibraries Include="$(LibrarySourceFolder)\Authentication\Authentication.sln"
<NonAutoRestLibraries Include="$(LibrarySourceFolder)\Authentication\Authentication.sln"
Condition=" '$(Scope)' == 'all' or '$(Scope)' == 'Authentication' " />
<!--
<NonAutoRestLibraries Include="$(LibrarySourceFolder)\Authentication\Authentication.sln"
Condition=" ('$(Scope)' == 'all' or '$(Scope)' == 'Authentication') and Exists('$(LibrarySourceFolder)\Authentication\Authentication.sln')" />
-->

</ItemGroup>
<Message Text="Non-AutoRest Libraries: @(NonAutoRestLibraries)" />

<Message Text="Ensure 7zip is available" />
<Exec
Command="$(LibraryToolsFolder)\AzCopy\AzCopy.exe /Source:https://azuresdktools.blob.core.windows.net/7-zip /S /Dest:$(ZipExeFolder) /Y"
Condition="!Exists('$(ZipExe)')" />

</Target>

<Target Name="Build" DependsOnTargets="BuildClientRuntime;BuildMsBuildTask;PrepareForAutoRestLibraries;RestoreNugetPackages">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="RunPublishTest" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="DebugTask" AssemblyFile="$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks.dll" />
<PropertyGroup>
<LibrarySourceFolder Condition="'$(PublishTestProjects)' == 'true'">$(LibraryToolsFolder)\Microsoft.WindowsAzure.Build.Tasks\Build.Tasks.Tests\TestPublishProjects</LibrarySourceFolder>
<LibraryNugetPackageFolder>$(LibraryRoot)\packages</LibraryNugetPackageFolder>
<FxTargetList>portable;net40;net45</FxTargetList>
<NuGetPublishingSource>$(USERPROFILE)\nugetPublish</NuGetPublishingSource>
<NuGetKey>1234</NuGetKey>
</PropertyGroup>

<ItemGroup>
<!-- <LibrariesToBuild Remove="@(LibrariesToBuild)"/> -->
<LibrariesToBuild Include="$(LibrarySourceFolder)\$(Scope)\**\*.sln" Condition=" '$(Scope)' != 'All' Or '$(Scope)' == '' " />
<LibrariesToBuild Include="$(LibrarySourceFolder)\**\*.sln" Condition=" '$(Scope)' == 'All' Or '$(Scope)' == '' " />
<LibraryFxTargetList Include="$(FxTargetList)" />
<AutoRestLibraryFxTargetList Include="portable;net45" />
</ItemGroup>
<!--
<Import Project="$(LibrarySourceFolder)\MultiProjectMultiSln\CSProjTestPublish\CSProjTestPublish.nuget.proj" />
-->
<Target Name="OnePackageInit">
<!-- Use Case: You have to provide scope here, the way msbuild builds it's build graph for imports
and the way we have authored our DynamicNuSpec targets
msbuild build.proj /p:PublishTestProjects=true /t:Publish_OnePackage /p:Scope=MultiProjectMultiSln
-->
<Message Text="Executing 'OnePackageInit'" />
<PropertyGroup>
<Scope>MultiProjectMultiSln</Scope>
<PackageName>CSProjTestPublish</PackageName>
</PropertyGroup>
<ItemGroup>
<LibrariesToBuild Remove="@(LibrariesToBuild)" Condition=" '@(LibrariesToBuild)' != '' " />
<LibrariesToBuild Include="$(LibrarySourceFolder)\$(Scope)\**\*.sln" />
</ItemGroup>
<Message Text="Scope: '$(Scope)', PackageName: '$(PackageName)'"/>
<Error Text="No Project found to be built." Condition=" '@(LibrariesToBuild)' == '' " />
</Target>

<Target Name="MultiPackageInit">
<Message Text="Executing 'MultiPackageInit'" />
<PropertyGroup>
<Scope>MultiProjectSingleSln</Scope>
<PackageName>Sdk RP1_MgmtPlane RP2_SDK.Test</PackageName>
</PropertyGroup>
<ItemGroup>
<LibrariesToBuild Remove="@(LibrariesToBuild)" Condition=" '@(LibrariesToBuild)' != '' " />
<LibrariesToBuild Include="$(LibrarySourceFolder)\$(Scope)\**\*.sln" />
</ItemGroup>
<Error Text="No Project found to be built." Condition=" '@(LibrariesToBuild)' == '' " />
</Target>

<Target Name="Publish_MultiplePackage" DependsOnTargets="MultiPackageInit;TestInit;CommonSteps">
<Message Text="'Publish_MutiplePackage' completed"/>
</Target>

<Target Name="Publish_OnePackage" DependsOnTargets="OnePackageInit;TestInit;CommonSteps">
<Message Text="'Publish_OnePackage' succeeded" Condition="Exists('$(NuGetPublishingSource)\CSProjTestPublish.0.0.1.nupkg')" />
<Error Text="'Publish_OnePackage' failed" Condition="!Exists('$(NuGetPublishingSource)\CSProjTestPublish.0.0.1.nupkg')" />
</Target>

<Target Name="CommonSteps" DependsOnTargets="prepareforautorestlibraries;BuildTestPackages;Package;Publish" />

<Target Name="TestInit" >
<Message Text="Trying to Create directory $(NuGetPublishingSource)" Condition="!Exists($(NuGetPublishingSource))" />
<MakeDir Directories="$(NuGetPublishingSource)" Condition="!Exists($(NuGetPublishingSource))" />
<Message Text="Test Publishing directory detected $(NuGetPublishingSource)" Condition="Exists($(NuGetPublishingSource))" />
<Error Text="Directory creation failed for '$(NuGetPublishingSource)'" Condition="!Exists($(NuGetPublishingSource))" />
</Target>

<Target Name="BuildTestPackages">
<Message Text="Non-NetCore Test Packages Libs to be built: @(Non_NetCore_AutoRestLibraries)" />
<MSBuild Projects="@(Non_NetCore_AutoRestLibraries)"
Targets="Build" />

<Message Text="NetCore Test Packages Libs to be built: @(Non_NetCore_AutoRestLibraries)" />
<Exec Command="dotnet restore" WorkingDirectory="%(NetCore_AutoRestLibraries.Library)" Condition=" @(NetCore_AutoRestLibraries) != '' "/>
<Exec Command="dotnet build --configuration $(Configuration)" WorkingDirectory="%(NetCore_AutoRestLibraries.Library)" Condition=" '%(NetCore_AutoRestLibraries.Library)'!= '' "/>

<Message Text="Building packages completed. Publishing not done" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>424ee98f-19b5-4c8d-81a0-9e2891a20b36</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CSProjTestPublish</RootNamespace>
<AssemblyName>CSProjTestPublish</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoRestProjects>true</AutoRestProjects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<Import Project="..\..\..\..\..\Library.Settings.targets" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Xml.Linq"/>
<Reference Include="System.Data.DataSetExtensions"/>
<Reference Include="Microsoft.CSharp"/>
<Reference Include="System.Data"/>
<Reference Include="System.Net.Http"/>
<Reference Include="System.Xml"/>
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<SdkNuGetPackage Include="CSProjTestPublish">
<PackageVersion>0.0.1</PackageVersion>
<Folder>$(MSBuildThisFileDirectory)</Folder>
</SdkNuGetPackage>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>CSProjTestPublish</id>
<version>$version$</version>
<title>CSProjTestPublish</title>
<authors>CSProjTestPublish</authors>
<owners>CSProjTestPublish</owners>
<licenseUrl>http://aka.ms/windowsazureapache2</licenseUrl>
<projectUrl>http://aka.ms/windowsazureapache2</projectUrl>
<iconUrl>http://aka.ms/windowsazureapache2</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>This is a test library used to test publish process to nuget</description>
<summary>This is a test library used to test publish process to nuget.</summary>
<releaseNotes/>
<tags>CSProjTestPublish</tags>
<dependencies>
<group targetFramework=".NETFramework4.5">
</group>
</dependencies>
</metadata>
<files>
<file src="..\binaries\net45\CSProjTestPublish.dll" target="lib\net45" />
<file src="..\binaries\net45\CSProjTestPublish.pdb" target="lib\net45" />
</files>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSProjTestPublish", "CSProjTestPublish.csproj", "{424EE98F-19B5-4C8D-81A0-9E2891A20B36}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Net40-Debug|Any CPU = Net40-Debug|Any CPU
Net40-Release|Any CPU = Net40-Release|Any CPU
Net45-Debug|Any CPU = Net45-Debug|Any CPU
Net45-Release|Any CPU = Net45-Release|Any CPU
Portable-Debug|Any CPU = Portable-Debug|Any CPU
Portable-Release|Any CPU = Portable-Release|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Debug|Any CPU.Build.0 = Debug|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Net40-Debug|Any CPU.ActiveCfg = Net40-Debug|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Net40-Debug|Any CPU.Build.0 = Net40-Debug|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Net40-Release|Any CPU.ActiveCfg = Net40-Release|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Net40-Release|Any CPU.Build.0 = Net40-Release|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Net45-Debug|Any CPU.ActiveCfg = Net45-Debug|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Net45-Debug|Any CPU.Build.0 = Net45-Debug|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Net45-Release|Any CPU.ActiveCfg = Net45-Release|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Net45-Release|Any CPU.Build.0 = Net45-Release|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Portable-Debug|Any CPU.ActiveCfg = Portable-Debug|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Portable-Debug|Any CPU.Build.0 = Portable-Debug|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Portable-Release|Any CPU.ActiveCfg = Portable-Release|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Portable-Release|Any CPU.Build.0 = Portable-Release|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Release|Any CPU.ActiveCfg = Release|Any CPU
{424EE98F-19B5-4C8D-81A0-9E2891A20B36}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSProjTestPublish
{
public class Class1
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CSProjTestPublish")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CSProjTestPublish")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("424ee98f-19b5-4c8d-81a0-9e2891a20b36")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("0.0.1.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace NetCoreTestPublish
{
public class Class1
{
public Class1()
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NetCoreTestPublish", "NetCoreTestPublish.xproj", "{4E25F50B-E3E9-4D84-AF23-629694F3FBB9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4E25F50B-E3E9-4D84-AF23-629694F3FBB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E25F50B-E3E9-4D84-AF23-629694F3FBB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E25F50B-E3E9-4D84-AF23-629694F3FBB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E25F50B-E3E9-4D84-AF23-629694F3FBB9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>

<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>4e25f50b-e3e9-4d84-af23-629694f3fbb9</ProjectGuid>
<RootNamespace>NetCoreTestPublish</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>

<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
Loading

0 comments on commit e476727

Please sign in to comment.