Add MSBuild task with MDP (#128)
This commit is contained in:
Родитель
98b12ea29a
Коммит
0cfc81c03f
|
@ -0,0 +1,442 @@
|
|||
//
|
||||
// Copyright (c) .NET Foundation and Contributors
|
||||
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
using System.ComponentModel;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using nanoFramework.Tools.Utilities;
|
||||
using System.Xml;
|
||||
using nanoFramework.Tools.MetadataProcessor.Core;
|
||||
using Mono.Cecil;
|
||||
|
||||
namespace nanoFramework.Tools.MetadataProcessor.MsBuildTask
|
||||
{
|
||||
[Description("MetaDataProcessorTaskEntry")]
|
||||
public class MetaDataProcessorTask : Task
|
||||
{
|
||||
|
||||
#region public properties for the task
|
||||
|
||||
/// <summary>
|
||||
/// Array of nanoFramework assemblies to be passed to MetaDataProcessor in -loadHints switch
|
||||
/// </summary>
|
||||
public ITaskItem[] LoadHints { get; set; }
|
||||
|
||||
public ITaskItem[] IgnoreAssembly { get; set; }
|
||||
|
||||
public ITaskItem[] Load { get; set; }
|
||||
|
||||
public ITaskItem[] LoadDatabase { get; set; }
|
||||
|
||||
public string LoadStrings { get; set; }
|
||||
|
||||
public ITaskItem[] ExcludeClassByName { get; set; }
|
||||
|
||||
public ITaskItem[] ImportResources { get; set; }
|
||||
|
||||
public string Parse { get; set; }
|
||||
|
||||
public string GenerateStringsTable { get; set; }
|
||||
|
||||
public string Compile { get; set; }
|
||||
|
||||
public bool Verbose { get; set; }
|
||||
|
||||
public bool VerboseMinimize { get; set; }
|
||||
|
||||
public bool NoByteCode { get; set; }
|
||||
|
||||
public bool NoAttributes { get; set; }
|
||||
|
||||
public ITaskItem[] CreateDatabase { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Parameter to enable stubs generation step.
|
||||
/// </summary>
|
||||
public bool GenerateStubs { get; set; } = false;
|
||||
|
||||
public string GenerateSkeletonFile { get; set; }
|
||||
|
||||
public string GenerateSkeletonName { get; set; }
|
||||
|
||||
public string GenerateSkeletonProject { get; set; }
|
||||
|
||||
public string GenerateDependency { get; set; }
|
||||
|
||||
public string CreateDatabaseFile { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Option to generate skeleton project without Interop support.
|
||||
/// This is required to generate Core Libraries.
|
||||
/// Default is false, meaning that Interop support will be used.
|
||||
/// </summary>
|
||||
public bool SkeletonWithoutInterop { get; set; } = false;
|
||||
|
||||
public bool Resolve { get; set; }
|
||||
|
||||
public string SaveStrings { get; set; }
|
||||
|
||||
public bool DumpMetadata { get; set; }
|
||||
|
||||
public string DumpFile { get; set; }
|
||||
|
||||
public string DumpExports { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flag to set when compiling a Core Library.
|
||||
/// </summary>
|
||||
public bool IsCoreLibrary { get; set; } = false;
|
||||
|
||||
private readonly List<ITaskItem> _filesWritten = new List<ITaskItem>();
|
||||
|
||||
[Output]
|
||||
public ITaskItem[] FilesWritten { get { return _filesWritten.ToArray(); } }
|
||||
|
||||
[Output]
|
||||
public ITaskItem NativeChecksum { get { return new TaskItem(_nativeChecksum); } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region internal fields for MetadataProcessor
|
||||
|
||||
private AssemblyDefinition _assemblyDefinition;
|
||||
private nanoAssemblyBuilder _assemblyBuilder;
|
||||
private readonly IDictionary<string, string> _loadHints =
|
||||
new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
private readonly List<string> _classNamesToExclude = new List<string>();
|
||||
private string _nativeChecksum = "";
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
// report to VS output window what step the build is
|
||||
Log.LogCommandLine(MessageImportance.Normal, "Starting nanoFramework MetadataProcessor...");
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// developer note: to debug this task set an environment variable like this:
|
||||
// set NFBUILD_TASKS_DEBUG=1
|
||||
// this will cause the execution to pause bellow so a debugger can be attached
|
||||
DebuggerHelper.WaitForDebuggerIfEnabled(TasksConstants.BuildTaskDebugVar);
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
try
|
||||
{
|
||||
// execution of the metadata processor have to be carried in the appropriate order
|
||||
// failing to do so will most likely cause the task to fail
|
||||
|
||||
// load hints for referenced assemblies
|
||||
if (LoadHints != null &&
|
||||
LoadHints.Any())
|
||||
{
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, "Processing load hints...");
|
||||
|
||||
foreach (var hint in LoadHints)
|
||||
{
|
||||
var assemblyName = Path.GetFileNameWithoutExtension(hint.GetMetadata("FullPath"));
|
||||
var assemblyPath = hint.GetMetadata("FullPath");
|
||||
|
||||
_loadHints[assemblyName] = assemblyPath;
|
||||
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, $"Adding load hint: {assemblyName} @ '{assemblyPath}'");
|
||||
}
|
||||
}
|
||||
|
||||
// class names to exclude from processing
|
||||
if (ExcludeClassByName != null &&
|
||||
ExcludeClassByName.Any())
|
||||
{
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, "Processing class exclusion list...");
|
||||
|
||||
foreach (var className in ExcludeClassByName)
|
||||
{
|
||||
_classNamesToExclude.Add(className.ToString());
|
||||
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, $"Adding '{className.ToString()}' to collection of classes to exclude");
|
||||
}
|
||||
}
|
||||
|
||||
// Analyses a .NET assembly
|
||||
if (!string.IsNullOrEmpty(Parse))
|
||||
{
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, $"Analysing .NET assembly {Path.GetFileNameWithoutExtension(Parse)}...");
|
||||
|
||||
ExecuteParse(Parse);
|
||||
}
|
||||
|
||||
// compiles an assembly into nanoCLR format
|
||||
if (!string.IsNullOrEmpty(Compile))
|
||||
{
|
||||
// sanity check for missing parse
|
||||
if (string.IsNullOrEmpty(Parse))
|
||||
{
|
||||
// can't compile without analysing first
|
||||
throw new ArgumentException("Can't compile without first analysing a .NET Assembly. Check the targets file for a missing option invoking MetadataProcessor Task.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, $"Compiling {Path.GetFileNameWithoutExtension(Compile)} into nanoCLR format...");
|
||||
|
||||
ExecuteCompile(Compile);
|
||||
}
|
||||
}
|
||||
|
||||
// generate skeleton files with stubs to add native code for an assembly
|
||||
if (GenerateStubs)
|
||||
{
|
||||
if (string.IsNullOrEmpty(GenerateSkeletonFile))
|
||||
{
|
||||
// can't generate skeleton without GenerateSkeletonFile parameter
|
||||
throw new ArgumentException("Can't generate skeleton project without 'GenerateSkeletonFile'. Check the targets file for a missing parameter when invoking MetadataProcessor Task.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(GenerateSkeletonProject))
|
||||
{
|
||||
// can't generate skeleton without GenerateSkeletonProject parameter
|
||||
throw new ArgumentException("Can't generate skeleton project without 'GenerateSkeletonProject'. Check the targets file for a missing parameter when invoking MetadataProcessor Task.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(GenerateSkeletonName))
|
||||
{
|
||||
// can't generate skeleton without GenerateSkeletonName parameter
|
||||
throw new ArgumentException("Can't generate skeleton project without 'GenerateSkeletonName'. Check the targets file for a missing parameter when invoking MetadataProcessor Task.");
|
||||
}
|
||||
|
||||
// sanity check for missing compile (therefore parse too)
|
||||
if (string.IsNullOrEmpty(Compile))
|
||||
{
|
||||
// can't generate skeleton without compiling first
|
||||
throw new ArgumentException("Can't generate skeleton project without first compiling the .NET Assembly. Check the targets file for a missing option invoking MetadataProcessor Task.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, $"Generating skeleton '{GenerateSkeletonName}' for {GenerateSkeletonProject} \r\nPlacing files @ '{GenerateSkeletonFile}'");
|
||||
|
||||
ExecuteGenerateSkeleton(
|
||||
GenerateSkeletonFile,
|
||||
GenerateSkeletonName,
|
||||
GenerateSkeletonProject,
|
||||
SkeletonWithoutInterop);
|
||||
}
|
||||
}
|
||||
|
||||
RecordFilesWritten();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.LogErrorFromException(ex, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// need to dispose the AssemblyDefinition before leaving because Mono.Cecil assembly loading and resolution
|
||||
// operations leave the assembly file locked in the AppDomain preventing it from being open on subsequent Tasks
|
||||
// see https://github.com/nanoframework/Home/issues/553
|
||||
if (_assemblyDefinition != null)
|
||||
{
|
||||
_assemblyDefinition.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// if we've logged any errors that's because there were errors (WOW!)
|
||||
return !Log.HasLoggedErrors;
|
||||
}
|
||||
|
||||
private void RecordFileWritten(
|
||||
string file)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(file))
|
||||
{
|
||||
if (File.Exists(file))
|
||||
{
|
||||
_filesWritten.Add(new TaskItem(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RecordFilesWritten()
|
||||
{
|
||||
RecordFileWritten(SaveStrings);
|
||||
RecordFileWritten(GenerateStringsTable);
|
||||
RecordFileWritten(DumpFile);
|
||||
RecordFileWritten(DumpExports);
|
||||
RecordFileWritten(Compile);
|
||||
RecordFileWritten(Path.ChangeExtension(Compile, "pdbx"));
|
||||
RecordFileWritten(CreateDatabaseFile);
|
||||
RecordFileWritten(GenerateDependency);
|
||||
}
|
||||
|
||||
#region Metadata Processor helper methods
|
||||
|
||||
private void ExecuteParse(
|
||||
string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, "Parsing assembly...");
|
||||
|
||||
_assemblyDefinition = AssemblyDefinition.ReadAssembly(fileName,
|
||||
new ReaderParameters { AssemblyResolver = new LoadHintsAssemblyResolver(_loadHints) });
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Log.LogError($"Unable to parse input assembly file '{fileName}' - check if path and file exists.");
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteCompile(
|
||||
string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
// compile assembly (1st pass)
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, "Compiling assembly...");
|
||||
|
||||
_assemblyBuilder = new nanoAssemblyBuilder(
|
||||
_assemblyDefinition,
|
||||
_classNamesToExclude,
|
||||
Verbose,
|
||||
IsCoreLibrary);
|
||||
|
||||
using (var stream = File.Open(Path.ChangeExtension(fileName, "tmp"), FileMode.Create, FileAccess.ReadWrite))
|
||||
using (var writer = new BinaryWriter(stream))
|
||||
{
|
||||
_assemblyBuilder.Write(GetBinaryWriter(writer));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Log.LogError($"Unable to compile output assembly file '{fileName}' - check parse command results.");
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// OK to delete tmp PE file
|
||||
File.Delete(Path.ChangeExtension(fileName, "tmp"));
|
||||
|
||||
// minimize (has to be called after the 1st compile pass)
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, "Minimizing assembly...");
|
||||
|
||||
_assemblyBuilder.Minimize();
|
||||
|
||||
// compile assembly (2nd pass after minimize)
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, "Recompiling assembly...");
|
||||
|
||||
using (var stream = File.Open(fileName, FileMode.Create, FileAccess.ReadWrite))
|
||||
using (var writer = new BinaryWriter(stream))
|
||||
{
|
||||
_assemblyBuilder.Write(GetBinaryWriter(writer));
|
||||
}
|
||||
|
||||
// output PDBX
|
||||
using (var writer = XmlWriter.Create(Path.ChangeExtension(fileName, "pdbx")))
|
||||
{
|
||||
_assemblyBuilder.Write(writer);
|
||||
}
|
||||
|
||||
// output assembly metadata
|
||||
if (DumpMetadata)
|
||||
{
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, "Dumping assembly metadata...");
|
||||
|
||||
DumpFile = Path.ChangeExtension(fileName, "dump.txt");
|
||||
|
||||
nanoDumperGenerator dumper = new nanoDumperGenerator(
|
||||
_assemblyBuilder.TablesContext,
|
||||
DumpFile);
|
||||
dumper.DumpAll();
|
||||
}
|
||||
|
||||
// set environment variable with assembly native checksum
|
||||
Environment.SetEnvironmentVariable("AssemblyNativeChecksum", _assemblyBuilder.GetNativeChecksum(), EnvironmentVariableTarget.Process);
|
||||
|
||||
// store assembly native checksum
|
||||
_nativeChecksum = _assemblyBuilder.GetNativeChecksum();
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
Log.LogError($"Exception minimizing assembly: {ex.Message}.");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Log.LogError($"Exception minimizing assembly.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddClassToExclude(
|
||||
string className)
|
||||
{
|
||||
_classNamesToExclude.Add(className);
|
||||
}
|
||||
|
||||
private void ExecuteGenerateSkeleton(
|
||||
string file,
|
||||
string name,
|
||||
string project,
|
||||
bool withoutInteropCode)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Verbose) Log.LogCommandLine(MessageImportance.Normal, "Generating skeleton files...");
|
||||
|
||||
var skeletonGenerator = new nanoSkeletonGenerator(
|
||||
_assemblyBuilder.TablesContext,
|
||||
file,
|
||||
name,
|
||||
project,
|
||||
withoutInteropCode,
|
||||
IsCoreLibrary);
|
||||
|
||||
skeletonGenerator.GenerateSkeleton();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Log.LogError("Unable to generate skeleton files");
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteGenerateDependency(
|
||||
string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dependencyGenerator = new nanoDependencyGenerator(
|
||||
_assemblyDefinition,
|
||||
_assemblyBuilder.TablesContext,
|
||||
fileName);
|
||||
|
||||
using (var writer = XmlWriter.Create(fileName))
|
||||
{
|
||||
dependencyGenerator.Write(writer);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Log.LogError($"Unable to generate and write dependency graph for assembly file '{fileName}'.");
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private nanoBinaryWriter GetBinaryWriter(
|
||||
BinaryWriter writer)
|
||||
{
|
||||
return nanoBinaryWriter.CreateLittleEndianBinaryWriter(writer);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="$(VisualStudioVersion)" 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>{9B18784E-1BF2-47D1-BDD1-85B678F883F9}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>nanoFramework.Tools.MetadataProcessor.MsBuildTask</RootNamespace>
|
||||
<AssemblyName>nanoFramework.Tools.MetadataProcessor.MsBuildTask</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
<Deterministic>true</Deterministic>
|
||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||
<ContinuousIntegrationBuild Condition="'$(TF_BUILD)' == 'true'">True</ContinuousIntegrationBuild>
|
||||
</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>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>portable</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Build.Framework" />
|
||||
<Reference Include="Microsoft.Build.Utilities.v4.0" />
|
||||
<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="TasksConstants.cs" />
|
||||
<Compile Include="MetaDataProcessorTask.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utilities\DebuggerHelper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MetadataProcessor.Core\MetadataProcessor.Core.csproj">
|
||||
<Project>{e32f7d15-2499-440c-8026-4d5ee1c5ec3a}</Project>
|
||||
<Name>MetadataProcessor.Core</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.lock.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub">
|
||||
<Version>1.0.0</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Mono.Cecil">
|
||||
<Version>0.11.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="mustache-sharp">
|
||||
<Version>1.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Nerdbank.GitVersioning">
|
||||
<Version>3.3.37</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,21 @@
|
|||
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(".NET nanoFramework Metadata processor MSBuild Task library")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("nanoFramework")]
|
||||
[assembly: AssemblyProduct(".NET nanoFramework Metadata processor MSBuild Task library")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020 nanoFramework contributors")]
|
||||
[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)]
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
//
|
||||
// Copyright (c) .NET Foundation and Contributors
|
||||
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace nanoFramework.Tools
|
||||
{
|
||||
internal class TasksConstants
|
||||
{
|
||||
public const string BuildTaskDebugVar = "NFBUILD_TASKS_DEBUG";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Copyright (c) .NET Foundation and Contributors
|
||||
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
namespace nanoFramework.Tools.Utilities
|
||||
{
|
||||
internal static class DebuggerHelper
|
||||
{
|
||||
public static void WaitForDebuggerIfEnabled(string varName, int timeoutSeconds = 30)
|
||||
{
|
||||
|
||||
// this wait should be only available on debug build
|
||||
// to prevent unwanted wait on VS in machines where the variable is present
|
||||
#if DEBUG
|
||||
TimeSpan waitForDebugToAttach = TimeSpan.FromSeconds(timeoutSeconds);
|
||||
|
||||
var debugEnabled = Environment.GetEnvironmentVariable(varName, EnvironmentVariableTarget.User);
|
||||
|
||||
if (!string.IsNullOrEmpty(debugEnabled) && debugEnabled.Equals("1", StringComparison.Ordinal))
|
||||
{
|
||||
Console.WriteLine($".NET nanoFramework Metadata Processor msbuild instrumentation task debugging is enabled. Waiting {timeoutSeconds} seconds for debugger attachment...");
|
||||
|
||||
var currentProcessId = Process.GetCurrentProcess().Id;
|
||||
var currentProcessName = Process.GetProcessById(currentProcessId).ProcessName;
|
||||
Console.WriteLine(
|
||||
string.Format("Process Id: {0}, Name: {1}", currentProcessId, currentProcessName)
|
||||
);
|
||||
|
||||
// wait N seconds for debugger to attach
|
||||
while (!Debugger.IsAttached && waitForDebugToAttach.TotalSeconds > 0)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
waitForDebugToAttach -= TimeSpan.FromSeconds(1);
|
||||
}
|
||||
|
||||
Debugger.Break();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Content Include="$(OutDir)nanoFramework.Tools.MetadataProcessor.Core.dll">
|
||||
<InstallRoot>MSBuild</InstallRoot>
|
||||
<VSIXSubPath>nanoFramework\v1.0\</VSIXSubPath>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
</Content>
|
||||
<Content Include="$(OutDir)nanoFramework.Tools.MetadataProcessor.MsBuildTask.dll">
|
||||
<InstallRoot>MSBuild</InstallRoot>
|
||||
<VSIXSubPath>nanoFramework\v1.0\</VSIXSubPath>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
</Content>
|
||||
<Content Include="$(OutDir)Mono.Cecil.dll">
|
||||
<InstallRoot>MSBuild</InstallRoot>
|
||||
<VSIXSubPath>nanoFramework\v1.0\</VSIXSubPath>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
</Content>
|
||||
<Content Include="$(OutDir)Mono.Cecil.Pdb.dll">
|
||||
<InstallRoot>MSBuild</InstallRoot>
|
||||
<VSIXSubPath>nanoFramework\v1.0\</VSIXSubPath>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
</Content>
|
||||
<Content Include="$(OutDir)Mono.Cecil.Rocks.dll">
|
||||
<InstallRoot>MSBuild</InstallRoot>
|
||||
<VSIXSubPath>nanoFramework\v1.0\</VSIXSubPath>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
</Content>
|
||||
<Content Include="$(OutDir)mustache-sharp.dll">
|
||||
<InstallRoot>MSBuild</InstallRoot>
|
||||
<VSIXSubPath>nanoFramework\v1.0\</VSIXSubPath>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0"?>
|
||||
<package >
|
||||
<metadata>
|
||||
<id>nanoFramework.Tools.MetadataProcessor.MsBuildTask</id>
|
||||
<title>nanoFramework.Tools.MetadataProcessor.MsBuildTask</title>
|
||||
<version>$version$</version>
|
||||
<authors>nanoFramework project contributors</authors>
|
||||
<owners>nanoFramework project contributors,dotnetfoundation</owners>
|
||||
<description>
|
||||
Metadata Processor MSBuild task to be used internally by the VS nanoFramework extension.
|
||||
</description>
|
||||
<releaseNotes>
|
||||
</releaseNotes>
|
||||
<projectUrl>https://github.com/nanoframework/metadata-processor</projectUrl>
|
||||
<icon>images\nf-logo.png</icon>
|
||||
<license type="file">LICENSE.md</license>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<repository type="git" url="https://github.com/nanoframework/metadata-processor" commit="$commit$" />
|
||||
<copyright>Copyright (c) .NET Foundation and Contributors</copyright>
|
||||
<references></references>
|
||||
<tags>nanoFramework, nano Framework, NETNF, NETMF, Micro Framework, .net</tags>
|
||||
<dependencies>
|
||||
<dependency id="Mono.Cecil" version="0.11.3" />
|
||||
<dependency id="mustache-sharp" version="1.0.0" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="bin\Release\nanoFramework.Tools.MetadataProcessor.Core.dll" target="lib/net472" />
|
||||
<file src="bin\Release\nanoFramework.Tools.MetadataProcessor.MsBuildTask.dll" target="lib/net472" />
|
||||
<file src="nanoFramework.Tools.MetadataProcessor.MsBuildTask.targets" target="build" />
|
||||
<file src="..\nf-logo.png" target="images\" />
|
||||
<file src="..\LICENSE.md" target="" />
|
||||
</files>
|
||||
</package>
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"version": 1,
|
||||
"dependencies": {
|
||||
".NETFramework,Version=v4.7.2": {
|
||||
"Microsoft.SourceLink.GitHub": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.0.0, )",
|
||||
"resolved": "1.0.0",
|
||||
"contentHash": "aZyGyGg2nFSxix+xMkPmlmZSsnGQ3w+mIG23LTxJZHN+GPwTQ5FpPgDo7RMOq+Kcf5D4hFWfXkGhoGstawX13Q==",
|
||||
"dependencies": {
|
||||
"Microsoft.Build.Tasks.Git": "1.0.0",
|
||||
"Microsoft.SourceLink.Common": "1.0.0"
|
||||
}
|
||||
},
|
||||
"Mono.Cecil": {
|
||||
"type": "Direct",
|
||||
"requested": "[0.11.3, )",
|
||||
"resolved": "0.11.3",
|
||||
"contentHash": "DNYE+io5XfEE8+E+5padThTPHJARJHbz1mhbhMPNrrWGKVKKqj/KEeLvbawAmbIcT73NuxLV7itHZaYCZcVWGg=="
|
||||
},
|
||||
"mustache-sharp": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.0.0, )",
|
||||
"resolved": "1.0.0",
|
||||
"contentHash": "+RTxWGLH5p0ibl7XDbb8pOznAdqwxH3zic40eL1gq5xl8jZt3CFc04KSLLFWM3PgvlTzfbzDJfjzF7rCglqGAA=="
|
||||
},
|
||||
"Nerdbank.GitVersioning": {
|
||||
"type": "Direct",
|
||||
"requested": "[3.3.37, )",
|
||||
"resolved": "3.3.37",
|
||||
"contentHash": "YlDKV/gSHQGDThWSGqVyPfKeNP/kx1fj/NPFFgGc/cxzgIbXv4jtYOcbFOz3ZIeAKtpCcSAmVNDOikBs3OxI/A=="
|
||||
},
|
||||
"Microsoft.Build.Tasks.Git": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.0.0",
|
||||
"contentHash": "z2fpmmt+1Jfl+ZnBki9nSP08S1/tbEOxFdsK1rSR+LBehIJz1Xv9/6qOOoGNqlwnAGGVGis1Oj6S8Kt9COEYlQ=="
|
||||
},
|
||||
"Microsoft.SourceLink.Common": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.0.0",
|
||||
"contentHash": "G8DuQY8/DK5NN+3jm5wcMcd9QYD90UV7MiLmdljSJixi3U/vNaeBKmmXUqI4DJCOeWizIUEh4ALhSt58mR+5eg=="
|
||||
},
|
||||
"metadataprocessor.core": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Mono.Cecil": "0.11.3",
|
||||
"mustache-sharp": "1.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
".NETFramework,Version=v4.7.2/win": {},
|
||||
".NETFramework,Version=v4.7.2/win-x64": {},
|
||||
".NETFramework,Version=v4.7.2/win-x86": {}
|
||||
}
|
||||
}
|
|
@ -121,6 +121,7 @@ jobs:
|
|||
sourceFolder: $(Build.SourcesDirectory)
|
||||
Contents: |
|
||||
**\bin\Release\nanoFramework.Tools.MetaDataProcessor.exe
|
||||
**\bin\Release\nanoFramework.Tools.MetadataProcessor.MsBuildTask.dll
|
||||
TargetFolder: '$(Build.ArtifactStagingDirectory)'
|
||||
flattenFolders: true
|
||||
|
||||
|
@ -134,10 +135,10 @@ jobs:
|
|||
|
||||
- task: NuGetCommand@2
|
||||
condition: succeeded()
|
||||
displayName: Pack NuGet witj MDP tool
|
||||
displayName: Pack NuGet with MDP MSBuild task
|
||||
inputs:
|
||||
command: 'custom'
|
||||
arguments: 'pack MetadataProcessor.Core\package.nuspec -Version $(NBGV_NuGetPackageVersion) -properties commit="$(Build.SourceVersion)"'
|
||||
arguments: 'pack MetadataProcessor.MsBuildTask\package.nuspec -Version $(NBGV_NuGetPackageVersion) -properties commit="$(Build.SourceVersion)"'
|
||||
|
||||
- task: CopyFiles@1
|
||||
condition: succeeded()
|
||||
|
|
|
@ -35,37 +35,29 @@ git checkout --quiet develop | Out-Null
|
|||
####################
|
||||
# VS 2017
|
||||
|
||||
Write-Host "Updating nanoFramework.Tools.MetadataProcessor.Core package in VS2017 solution..."
|
||||
Write-Host "Updating nanoFramework.Tools.MetadataProcessor.MsBuildTask package in VS2017 solution..."
|
||||
|
||||
dotnet remove Tools.BuildTasks\Tools.BuildTasks.csproj package nanoFramework.Tools.MetadataProcessor.Core
|
||||
dotnet remove VisualStudio.Extension\VisualStudio.Extension.csproj package nanoFramework.Tools.MetadataProcessor.MsBuildTask
|
||||
|
||||
dotnet add Tools.BuildTasks\Tools.BuildTasks.csproj package nanoFramework.Tools.MetadataProcessor.Core --prerelease -s https://pkgs.dev.azure.com/nanoframework/feed/_packaging/sandbox/nuget/v3/index.json
|
||||
|
||||
dotnet remove VisualStudio.Extension\VisualStudio.Extension.csproj package nanoFramework.Tools.MetadataProcessor.Core
|
||||
|
||||
dotnet add VisualStudio.Extension\VisualStudio.Extension.csproj package nanoFramework.Tools.MetadataProcessor.Core --prerelease -s https://pkgs.dev.azure.com/nanoframework/feed/_packaging/sandbox/nuget/v3/index.json
|
||||
dotnet add VisualStudio.Extension\VisualStudio.Extension.csproj package nanoFramework.Tools.MetadataProcessor.MsBuildTask --prerelease -s https://pkgs.dev.azure.com/nanoframework/feed/_packaging/sandbox/nuget/v3/index.json
|
||||
|
||||
####################
|
||||
# VS 2019
|
||||
|
||||
Write-Host "Updating nanoFramework.Tools.MetadataProcessor.Core package in VS2019 solution..."
|
||||
Write-Host "Updating nanoFramework.Tools.MetadataProcessor.MsBuildTask package in VS2019 solution..."
|
||||
|
||||
dotnet remove Tools.BuildTasks-2019\Tools.BuildTasks.csproj package nanoFramework.Tools.MetadataProcessor.Core
|
||||
dotnet remove VisualStudio.Extension-2019\VisualStudio.Extension.csproj package nanoFramework.Tools.MetadataProcessor.MsBuildTask
|
||||
|
||||
dotnet add Tools.BuildTasks-2019\Tools.BuildTasks.csproj package nanoFramework.Tools.MetadataProcessor.Core --prerelease -s https://pkgs.dev.azure.com/nanoframework/feed/_packaging/sandbox/nuget/v3/index.json
|
||||
|
||||
dotnet remove VisualStudio.Extension-2019\VisualStudio.Extension.csproj package nanoFramework.Tools.MetadataProcessor.Core
|
||||
|
||||
dotnet add VisualStudio.Extension-2019\VisualStudio.Extension.csproj package nanoFramework.Tools.MetadataProcessor.Core --prerelease -s https://pkgs.dev.azure.com/nanoframework/feed/_packaging/sandbox/nuget/v3/index.json
|
||||
dotnet add VisualStudio.Extension-2019\VisualStudio.Extension.csproj package nanoFramework.Tools.MetadataProcessor.MsBuildTask --prerelease -s https://pkgs.dev.azure.com/nanoframework/feed/_packaging/sandbox/nuget/v3/index.json
|
||||
|
||||
#####################
|
||||
|
||||
"Bumping MetadataProcessor.Core to $packageTargetVersion." | Write-Host -ForegroundColor Cyan
|
||||
"Bumping MetadataProcessor.MsBuildTask to $packageTargetVersion." | Write-Host -ForegroundColor Cyan
|
||||
|
||||
# build commit message
|
||||
$commitMessage += "Bumps MetadataProcessor.Core to $packageTargetVersion.`n"
|
||||
$commitMessage += "Bumps MetadataProcessor.MsBuildTask to $packageTargetVersion.`n"
|
||||
# build PR title
|
||||
$prTitle = "Bumps MetadataProcessor.Core to $packageTargetVersion"
|
||||
$prTitle = "Bumps MetadataProcessor.MsBuildTask to $packageTargetVersion"
|
||||
|
||||
# need this line so nfbot flags the PR appropriately
|
||||
$commitMessage += "`n[version update]`n`n"
|
||||
|
|
|
@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||
version.json = version.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MetadataProcessor.MsBuildTask", "MetadataProcessor.MsBuildTask\MetadataProcessor.MsBuildTask.csproj", "{9B18784E-1BF2-47D1-BDD1-85B678F883F9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -27,6 +29,10 @@ Global
|
|||
{A9E02E14-7321-4B12-8AB5-9A0408ED8FD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A9E02E14-7321-4B12-8AB5-9A0408ED8FD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A9E02E14-7321-4B12-8AB5-9A0408ED8FD0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9B18784E-1BF2-47D1-BDD1-85B678F883F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9B18784E-1BF2-47D1-BDD1-85B678F883F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9B18784E-1BF2-47D1-BDD1-85B678F883F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9B18784E-1BF2-47D1-BDD1-85B678F883F9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
|
||||
"version": "2.31",
|
||||
"version": "2.32",
|
||||
"release": {
|
||||
"branchName" : "release-v{version}",
|
||||
"versionIncrement" : "build",
|
||||
|
|
Загрузка…
Ссылка в новой задаче