![]() |
VOOZH | about |
dotnet add package Black.Beard.Build --version 1.0.140
NuGet\Install-Package Black.Beard.Build -Version 1.0.140
<PackageReference Include="Black.Beard.Build" Version="1.0.140" />
<PackageVersion Include="Black.Beard.Build" Version="1.0.140" />Directory.Packages.props
<PackageReference Include="Black.Beard.Build" />Project file
paket add Black.Beard.Build --version 1.0.140
#r "nuget: Black.Beard.Build, 1.0.140"
#:package Black.Beard.Build@1.0.140
#addin nuget:?package=Black.Beard.Build&version=1.0.140Install as a Cake Addin
#tool nuget:?package=Black.Beard.Build&version=1.0.140Install as a Cake Tool
Helpers for compile Csharp with Roslyn. The way use the tool installed on your machine. It does'nt work if dotnet is not installed.
Sample the use Black.Beard.Build for create a csproj
//Usings
using Bb.Build;
using System;
using System.IO;
// create a folder for store the generated project file
var name = "Black.Beard.tests";
var dir = new DirectoryInfo(Path.Combine(this._baseDirectory.FullName, name));
var project = MsProjectsForBuild
.CreateProject((name, dir)
.Sdk(ProjectSdk.MicrosoftNETSdk) // Specify the target build
.SetPropertyGroup(c => // set the properies of the build
{
c.TargetFramework(TargetFramework.Net6)
.RootNamespace("Bb")
.Description("My description")
.RepositoryUrl(new System.Uri("http://github.com"))
;
})
.Packages(p => // Reference packages
{
p.PackageReference("Black.Beard.ComponentModel", new Version("1.0.36"))
.PackageReference("Black.Beard.Helpers.ContentLoaders", new Version("1.0.8"))
;
});
// Build
var result = project.Build(inMemory: true, load: true);
// fetch the new assembly
var assembly = project.Assembly;
or the helper
var project = MsProjects.CreateCsProject(dir.FullName, name,
TargetFramework.Net6,
"Bb"
)
.SetPropertyGroup(a =>
{
a.Description("MyDescription");
})
.Packages(p =>
{
p.PackageReference("Black.Beard.ComponentModel", new Version("1.0.36"))
.PackageReference("Black.Beard.Helpers.ContentLoaders", new Version("1.0.8"))
;
});
This way use Roslyn for generate the assembly
// Use NJsonSchema for generate json schema
JsonSchema schema = JsonSchema.FromType(typeof(Sample1));
// Helper for manipulate codeDom object
var samples = "CodeDOMSample".ToNamespace()
.Import("System") // append usings
.AppendPoco(schema) // add a poco class from schema
.ToCSharp(Path.Combine(_dir.FullName, "class1.cs")) // Generate csharp code
;
// compile
AssemblyResult assembly = GetCsharpBuilder(samples.FullName);
// consumme the result assembly
if (assembly.Success)
{
var ass = assembly.LoadAssembly();
var type = ass.GetTypes().First(c => c.Name == "Sample1");
Assert.NotNull(type);
var property = type.GetProperties().FirstOrDefault(c => nameof(Sample1.Name) == c.Name);
Assert.NotNull(property);
}
else
{
var payload = File.ReadAllText(samples.FullName);
throw new Exception();
}
private static Bb.Compilers.AssemblyResult GetCsharpBuilder(string filepathCode)
{
var fileInfo = new FileInfo(filepathCode);
// Build assembly
Action<CSharpCompilationOptions> action = (r) =>
{
};
BuildCSharp builder = new BuildCSharp()
{
ResolveAssembliesInCode = true,
Debug = true,
LanguageVersion = LanguageVersion.CSharp7,
}
.AddSource(fileInfo)
.Suppress("CS1702", "CS1998")
;
// System.Collections
builder.References.AddRange(
typeof(object),
typeof(RequiredAttribute)
);
var assembly = builder.Build();
return assembly;
}
var builder = ProjectRoslynBuilderHelper.CreateCsharpBuild("project.csproj", true);
var result = builder.Build();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.140 | 352 | 4/14/2025 |
| 1.0.138 | 326 | 4/14/2025 |
| 1.0.137 | 292 | 4/3/2025 |
| 1.0.136 | 279 | 4/1/2025 |
| 1.0.135 | 294 | 4/1/2025 |
| 1.0.134 | 284 | 4/1/2025 |
| 1.0.133 | 235 | 1/27/2025 |
| 1.0.132 | 247 | 12/21/2024 |
| 1.0.131 | 232 | 12/7/2024 |
| 1.0.130 | 241 | 11/27/2024 |
| 1.0.129 | 242 | 11/24/2024 |
| 1.0.128 | 215 | 11/19/2024 |
| 1.0.127 | 230 | 11/19/2024 |
| 1.0.126 | 232 | 11/18/2024 |
| 1.0.125 | 220 | 11/17/2024 |
| 1.0.124 | 229 | 11/17/2024 |
| 1.0.123 | 236 | 11/17/2024 |
| 1.0.122 | 217 | 11/17/2024 |
| 1.0.121 | 233 | 11/17/2024 |
| 1.0.120 | 231 | 10/28/2024 |