Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b2438fe
Addong single unit creation to support anoFramework
Ellerbach Sep 17, 2020
ee3a667
Removing decimal based quantities as not supported in nanoFramework
Ellerbach Sep 17, 2020
b9c9da5
Adjusting generator based on PR comments
Ellerbach Oct 6, 2020
6dc5ac6
readjusting build.props
Ellerbach Oct 6, 2020
4f57ec9
WIP Update build scripts, gives msbuild error MSB4057
angularsen Oct 4, 2020
ad17dc8
Recreating nanoFramework elements
Ellerbach Apr 10, 2021
b47d2a9
Move all nanoFramework generated projects to its own folder
josesimoes Apr 12, 2021
8368707
Rework .NET nanoFramework generator
josesimoes Apr 12, 2021
37ed1a4
Init PS1 installs .NET nanoFramework VS extension
josesimoes Apr 12, 2021
706c6c7
Build PS1 now calls msbuild to build .NET nanoFramework solution
josesimoes Apr 12, 2021
5b838d8
Fix nanoFramework generator
josesimoes Apr 12, 2021
50fdd4c
Package generator now grabs the latest version directly from NuGet
josesimoes Apr 12, 2021
081bec2
Fix installer for nanoFramework VS extension
josesimoes Apr 12, 2021
cd90aa5
Improve generator
josesimoes Apr 12, 2021
2114987
Add missing restore step before building nanoFramework solution
josesimoes Apr 12, 2021
ea5a06a
Updating generated code for nanoFramework
josesimoes Apr 12, 2021
88e441b
Move nanoFramework solution file to root
josesimoes Apr 30, 2021
33cef30
Update build PS1 for building nanoFramework nugets
josesimoes Apr 30, 2021
8809988
Add nuspec for Temperature unit
josesimoes Apr 30, 2021
bac50c1
Add DocumentationFile to nano project generator
josesimoes Apr 30, 2021
f4f43eb
Add DocumentationFile to all nfproj files
josesimoes Apr 30, 2021
cf23162
Changes in nuspec after review
josesimoes Apr 30, 2021
699f3e2
Adjust nuget description following review
josesimoes May 1, 2021
c8acf13
Add nuspecs for more units
josesimoes May 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 27 additions & 1 deletion Build/build-functions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ if ($msbuild) {
$msbuild = join-path $msbuild 'MSBuild\Current\Bin\MSBuild.exe'
}

import-module $PSScriptRoot\build-pack-nano-nugets.psm1

function Remove-ArtifactsDir {
if (Test-Path $artifactsDir) {
write-host -foreground blue "Clean up...`n"
Expand All @@ -25,7 +27,7 @@ function Update-GeneratedCode {
write-host -foreground blue "Generate code...END`n"
}

function Start-Build([boolean] $IncludeWindowsRuntimeComponent = $false) {
function Start-Build([boolean] $IncludeWindowsRuntimeComponent = $false, [boolean] $IncludeNanoFramework = $false) {
write-host -foreground blue "Start-Build...`n---"

$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.msbuild.log"
Expand Down Expand Up @@ -54,6 +56,22 @@ function Start-Build([boolean] $IncludeWindowsRuntimeComponent = $false) {
if ($lastexitcode -ne 0) { exit 1 }
}

if (-not $IncludeNanoFramework)
{
write-host -foreground yellow "Skipping .NET nanoFramework build."
}
else
{
$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.NanoFramework.msbuild.log"
$appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerDll") { "/logger:$appVeyorLoggerDll" } else { "" }

# msbuild does not auto-restore nugets for this project type
& "nuget" restore "$root\UnitsNet.NanoFramework\GeneratedCode\UnitsNet.nanoFramework.sln"
# now build
& "$msbuild" "$root\UnitsNet.NanoFramework\GeneratedCode\UnitsNet.nanoFramework.sln" /verbosity:minimal /p:Configuration=Release $fileLoggerArg $appVeyorLoggerArg
if ($lastexitcode -ne 0) { exit 1 }
}

write-host -foreground blue "Start-Build...END`n"
}

Expand Down Expand Up @@ -115,6 +133,14 @@ function Start-PackNugets {
& $nuget pack "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
}

if (-not $IncludeNanoFramework) {
write-host -foreground yellow "Skipping nanoFramework nuget pack."
} else {
write-host -foreground yellow "nanoFramework project not yet supported by dotnet CLI, using nuget.exe instead"
Build-NanoNugets
}


write-host -foreground blue "Pack nugets...END`n"
}

Expand Down
11 changes: 11 additions & 0 deletions Build/build-pack-nano-nugets.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$root = "$PSScriptRoot\.."
$nugetOutDir = "$root\Artifacts\NuGet"
$nuget = "$root\Tools\NuGet.exe"

function Build-NanoNugets {

& $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Temperature\UnitsNet.NanoFramework.Temperature.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"

}

export-modulemember -function Build-NanoNugets
7 changes: 4 additions & 3 deletions Build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
some large, extra Visual Studio features to be installed.
.EXAMPLE
powershell ./build.ps1
powershell ./build.ps1 -skipUWP
powershell ./build.ps1 -IncludeWindowsRuntimeComponent -IncludeNanoFramework

.NOTES
Author: Andreas Gullberg Larsen
Last modified: Jan 21, 2018
#>
[CmdletBinding()]
Param(
[switch] $IncludeWindowsRuntimeComponent
[switch] $IncludeWindowsRuntimeComponent,
[switch] $IncludeNanoFramework
)

remove-module build-functions -ErrorAction SilentlyContinue
Expand All @@ -31,7 +32,7 @@ try {

Remove-ArtifactsDir
Update-GeneratedCode
Start-Build -IncludeWindowsRuntimeComponent $IncludeWindowsRuntimeComponent
Start-Build -IncludeWindowsRuntimeComponent $IncludeWindowsRuntimeComponent -IncludeNanoFramework $IncludeNanoFramework
Start-Tests
Start-PackNugets
Compress-ArtifactsAsZip
Expand Down
24 changes: 24 additions & 0 deletions Build/init.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@ if (-not (Test-Path "$root/Tools/reportgenerator.exe")) {
Write-Host -Foreground Green "Download dotnet-reportgenerator-globaltool...OK."
}

# Install .NET nanoFramework build components

Write-Host "Installing .NET nanoFramework VS extension..."

[System.Net.WebClient]$webClient = New-Object System.Net.WebClient
$webClient.UseDefaultCredentials = $true

$vsixFeedXml = Join-Path -Path $tempDir -ChildPath "vs-extension-feed.xml"
$webClient.DownloadFile("http://vsixgallery.com/feed/author/nanoframework", $vsixFeedXml)
[xml]$feedDetails = Get-Content $vsixFeedXml

$extensionUrl = $feedDetails.feed.entry[1].content.src
$vsixPath = Join-Path -Path $tempDir -ChildPath "nf-extension.zip"
$extensionVersion = $feedDetails.feed.entry[0].Vsix.Version
$webClient.DownloadFile($extensionUrl,$vsixPath)
Expand-Archive -LiteralPath $vsixPath -DestinationPath $tempDir\nf-extension\ | Write-Host

$VsWherePath = "${env:PROGRAMFILES(X86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$VsPath = $(&$VsWherePath -latest -property installationPath)
$msbuildPath = Join-Path -Path $VsPath -ChildPath "\MSBuild"
Copy-Item -Path "$tempDir\nf-extension\`$MSBuild\nanoFramework" -Destination $msbuildPath -Recurse

Write-Host "Installed VS extension v$extensionVersion"

# Cleanup
[system.io.Directory]::Delete($tempDir, $true) | out-null

Expand Down
1 change: 1 addition & 0 deletions CodeGen/CodeGen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NuGet.Protocol" Version="5.9.0" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.2.0-alpha.19174.3" />
Expand Down
77 changes: 77 additions & 0 deletions CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Text;
using CodeGen.JsonTypes;

namespace CodeGen.Generators.NanoFrameworkGen
{
class ProjectGenerator: GeneratorBase
{
private readonly Quantity _quantity;

public ProjectGenerator(Quantity quantity)
{
_quantity = quantity ?? throw new ArgumentNullException(nameof(quantity));
}

public override string Generate()
{
Writer.WL($@"<?xml version=""1.0"" encoding=""utf-8""?>
<Project ToolsVersion=""15.0"" DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup Label=""Globals"">
<NanoFrameworkProjectSystemPath>$(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
</PropertyGroup>
<Import Project=""$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props"" Condition=""Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')"" />
<PropertyGroup>
<Configuration Condition="" '$(Configuration)' == '' "">Debug</Configuration>
<Platform Condition="" '$(Platform)' == '' "">AnyCPU</Platform>
<ProjectTypeGuids>{{11A8DD76-328B-46DF-9F39-F559912D0360}};{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}</ProjectTypeGuids>
<ProjectGuid>{{{Guid.NewGuid()}}}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<FileAlignment>512</FileAlignment>
<RootNamespace>UnitsNet</RootNamespace>
<AssemblyName>UnitsNet.{_quantity.Name}</AssemblyName>
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
<DocumentationFile>bin\$(Configuration)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>
<Import Project=""$(NanoFrameworkProjectSystemPath)NFProjectSystem.props"" Condition=""Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')"" />
<ItemGroup>
<Compile Include=""..\Quantities\{_quantity.Name}.g.cs"" />
<Compile Include=""..\Units\{_quantity.Name}Unit.g.cs"" />
<Compile Include=""..\Properties\AssemblyInfo.cs"" />
</ItemGroup>
<ItemGroup>
<Reference Include=""mscorlib, Version={NanoFrameworkGenerator.MscorlibVersion}, Culture=neutral, PublicKeyToken=c07d481e9758c731"">
<HintPath>..\packages\nanoFramework.CoreLibrary.{NanoFrameworkGenerator.MscorlibNuGetVersion}\lib\mscorlib.dll</HintPath>
<Private>True</Private>
<SpecificVersion>True</SpecificVersion>
</Reference>");

if(NanoFrameworkGenerator.ProjectsRequiringMath.Contains(_quantity.Name))
{
Writer.WL($@"
<Reference Include=""System.Math, Version={NanoFrameworkGenerator.MathVersion}, Culture=neutral, PublicKeyToken=c07d481e9758c731"">
<HintPath>..\packages\nanoFramework.System.Math.{NanoFrameworkGenerator.MathNuGetVersion}\lib\System.Math.dll</HintPath>
<Private>True</Private>
<SpecificVersion>True</SpecificVersion>
</Reference>");
}

Writer.WL(@"
</ItemGroup>
<ItemGroup>
<None Include=""packages.config"" />
</ItemGroup>
<Import Project=""$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets"" Condition=""Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')"" />
<ProjectExtensions>
<ProjectCapabilities>
<ProjectConfigurationsDeclaredAsItems />
</ProjectCapabilities>
</ProjectExtensions>
</Project>");

return Writer.ToString();
}
}
}
54 changes: 54 additions & 0 deletions CodeGen/Generators/NanoFrameworkGen/PropertyGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace CodeGen.Generators.NanoFrameworkGen
{
class PropertyGenerator : GeneratorBase
{
public override string Generate()
{
Writer.WL(GeneratedFileHeader);
Writer.W(@"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(""CUnitsNet"")]
[assembly: AssemblyDescription(""Get all the common units of measurement and the conversions between them. It is light-weight and thoroughly tested."")]
[assembly: AssemblyConfiguration("""")]
[assembly: AssemblyCompany(""Andreas Gullberg Larsen"")]
[assembly: AssemblyProduct(""nanoFramework UnitsNet"")]
[assembly: AssemblyCopyright(""Copyright 2013 Andreas Gullberg Larsen ([email protected])."")]
[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)]

// 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(""1.0.0.0"")]

//////////////////////////////////////////////////
// This assembly doens't require native support //
[assembly: AssemblyNativeVersion(""0.0.0.0"")]
//////////////////////////////////////////////////
");
return Writer.ToString();
}
}
}
Loading