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

Generate nuget package for System.Device.Gpio #28

Merged
merged 3 commits into from
Nov 8, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Language>C#</Language>
<TargetsWindows Condition="'$(RuntimeIdentifier)' == 'win'">true</TargetsWindows>
<TargetsLinux Condition="'$(RuntimeIdentifier)' == 'linux'">true</TargetsLinux>
<LangVersion>Latest</LangVersion>
</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
Expand Down
57 changes: 49 additions & 8 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,15 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />

<!-- Crosstargeting for RIDs -->
<PropertyGroup Condition="'$(RuntimeIdentifiers)' != '' And '$(RuntimeIdentifier)' == ''">
<IsCrossTargetingRIDs>true</IsCrossTargetingRIDs>
<IsCrossTargetingRIDs>true</IsCrossTargetingRIDs>
</PropertyGroup>
<Choose>
<When Condition="'$(IsCrossTargetingRIDs)' == 'true'">
<PropertyGroup>
<CrossTargetingRIDTargetsPath>$(MSBuildThisFileDirectory)eng\CrosstargetingRIDs.targets</CrossTargetingRIDTargetsPath>
</PropertyGroup>
</When>
</Choose>
<Import Project="$(CrossTargetingRIDTargetsPath)" Condition="Exists('$(CrossTargetingRIDTargetsPath)')" />
<When Condition="'$(IsCrossTargetingRIDs)' == 'true'">
<PropertyGroup>
<CrossTargetingRIDTargetsPath>$(MSBuildThisFileDirectory)eng\CrosstargetingRIDs.targets</CrossTargetingRIDTargetsPath>
</PropertyGroup>
</When>
</Choose>
<Import Project="$(CrossTargetingRIDTargetsPath)" Condition="Exists('$(CrossTargetingRIDTargetsPath)')" />

<!-- Packaging Targets -->
<PropertyGroup>
<IncludeRIDSpecificBuildOutput Condition="'$(IncludeRIDSpecificBuildOutput)' == '' And '$(RuntimeIdentifiers)' != ''">true</IncludeRIDSpecificBuildOutput>
<TargetsForTfmSpecificContentInPackage Condition="'$(IncludeRIDSpecificBuildOutput)' == 'true'">$(TargetsForTfmSpecificContentInPackage);_WalkEachRIDForBuildOutput;_GetReferenceAssemblyForPackage</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<ItemGroup>
<_RuntimeIdentifiers Include="$(RuntimeIdentifiers)" />
</ItemGroup>

<Target Name="_WalkEachRIDForBuildOutput">
<MSBuild
Condition="'$(IncludeRIDSpecificBuildOutput)' == 'true'"
Projects="$(MSBuildProjectFullPath)"
Targets="_GetBuildOutputWithRID"
Properties="RuntimeIdentifier=%(_RuntimeIdentifiers.Identity)">

<Output
TaskParameter="TargetOutputs"
ItemName="TfmSpecificPackageFile" />
</MSBuild>
</Target>

<Target Name="_GetReferenceAssemblyForPackage">
<ItemGroup>
<TfmSpecificPackageFile Include="$(TargetRefPath)">
<PackagePath>ref/$(TargetFramework)</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
</Target>

<Target Name="_GetBuildOutputWithRID" Returns="@(RIDSpecificPackageFile)">
<ItemGroup>
<RIDSpecificPackageFile Include="$(TargetPath)">
<PackagePath>runtimes/$(RuntimeIdentifier)/lib/$(TargetFramework)</PackagePath>
</RIDSpecificPackageFile>
</ItemGroup>
</Target>
</Project>
22 changes: 11 additions & 11 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,38 @@

<Target Name="BuildProduct">
<ItemGroup>
<_BuildProductProjects Include="$(MSBuildThisFileDirectory)src\System.Device.Gpio\System.Device.Gpio.csproj" />
<_BuildProductProjects Include="$(MSBuildThisFileDirectory)src\devices\Mcp3008\Mcp3008.csproj" />
<_BuildProductProjects Include="$(MSBuildThisFileDirectory)src\**\*.csproj" />
</ItemGroup>

<MSBuild Projects="@(_BuildProductProjects)" />
</Target>

<Target Name="BuildSamples">
<ItemGroup>
<_BuildSampleProjects Include="$(MSBuildThisFileDirectory)samples\led-blink\led-blink.csproj" />
<_BuildSampleProjects Include="$(MSBuildThisFileDirectory)samples\led-more-blinking-lights\led-more-blinking-lights.csproj" />
<_BuildSampleProjects Include="$(MSBuildThisFileDirectory)samples\trimpot\trimpot.csproj" />
<_ExcludeBuildSampleProjects Include="$(MSBuildThisFileDirectory)samples\pwm-led\pwm-led.csproj" />
<_BuildSampleProjects Include="$(MSBuildThisFileDirectory)samples\**\*.csproj" Exclude="@(_ExcludeBuildSampleProjects)" />
</ItemGroup>

<MSBuild Projects="@(_BuildSampleProjects)" />
</Target>

<Target Name="Restore">
<ItemGroup>
<_ProjectsToRestore Include="$(MSBuildThisFileDirectory)src\System.Device.Gpio\System.Device.Gpio.csproj" />
<_ProjectsToRestore Include="$(MSBuildThisFileDirectory)src\devices\Mcp3008\Mcp3008.csproj" />
<_ProjectsToRestore Include="$(MSBuildThisFileDirectory)samples\led-blink\led-blink.csproj" />
<_ProjectsToRestore Include="$(MSBuildThisFileDirectory)samples\led-more-blinking-lights\led-more-blinking-lights.csproj" />
<_ProjectsToRestore Include="$(MSBuildThisFileDirectory)samples\trimpot\trimpot.csproj" />
<_ProjectsToRestore Include="$(MSBuildThisFileDirectory)**\*.csproj" />
</ItemGroup>

<MSBuild Projects="@(_ProjectsToRestore)" Targets="Restore" />
</Target>

<Target Name="Test" />

<Target Name="Pack" />
<Target Name="Pack">
<ItemGroup>
<_ProjectsToPackage Include="$(MSBuildThisFileDirectory)src\**\*.csproj" />
</ItemGroup>

<MSBuild Projects="@(_ProjectsToPackage)" Targets="Pack" />
</Target>

<Target Name="Build" DependsOnTargets="$(BuildDependsOn)" />

Expand Down
1 change: 0 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionPrefix>1.0.0</VersionPrefix>
<PreReleaseVersionLabel>prerelease</PreReleaseVersionLabel>
</PropertyGroup>
</Project>
13 changes: 13 additions & 0 deletions src/System.Device.Gpio/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>
<!-- Packaging related properties -->
<PropertyGroup>
<MajorVersion>0</MajorVersion>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planning on sharing a version across packages?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to set the package version. It will also set the Assembly version for now but that is fine because I also want that to be 0.1.0.0. Once we ship a different version of assembly this will change.

<MinorVersion>1</MinorVersion>
<Description>This experimental package allows projects to access GPIO pins for the BCM2835 as used on Raspberry Pi.</Description>
<Copyright>Microsoft Corporation, All rights reserved.</Copyright>
<IncludeBuildOutput>false</IncludeBuildOutput>
<PackageTags>.NET Core GPIO Pins BCM2835 Raspberry Pi IoT</PackageTags>
</PropertyGroup>

<Import Project="..\..\Directory.Build.props" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We typically import this one at the beginning to respect the sdk convention in hierarchy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that that one will import the arcade sdk, which will set the Version of the package, so I want to set Major and Minor version first.

</Project>
10 changes: 5 additions & 5 deletions src/System.Device.Gpio/System.Device.Gpio.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>This experimental package allows projects to access GPIO pins for the BCM2835 as used on Raspberry Pi.</Description>
<Copyright>Microsoft Corporation, All rights reserved.</Copyright>
<TargetFramework>netstandard2.0</TargetFramework>
<RuntimeIdentifiers>win;linux-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win;linux</RuntimeIdentifiers>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageTags>.NET Core GPIO Pins BCM2835 Raspberry Pi IoT</PackageTags>
<LangVersion>7.3</LangVersion>
<!-- Only produce reference assembly in one of our inner builds -->
<ProduceReferenceAssembly Condition="'$(TargetsWindows)' == 'true'">true</ProduceReferenceAssembly>
<TargetRefPath>$(OutputPath)$(TargetFramework)\$(MSBuildProjectName).dll</TargetRefPath>
<IsPackable>true</IsPackable>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you had to set a IncludeBuildOutput property and set it to false so that it doesn't include it in the package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is set in the Directory.Build.props of this project. I wanted to move all the packaging related things over there, except for this property so that when we look at the project we know that this project will generate a package.

</PropertyGroup>
<ItemGroup>
<Compile Remove="winmd\**" />
Expand Down