feat: support .NET
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Greeting\Greeting.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
public class Greeting_Should
|
||||
{
|
||||
[Fact]
|
||||
public void Greeting_PrintName()
|
||||
{
|
||||
var name = "Dagger Test";
|
||||
var expect = "Hi Dagger Test!";
|
||||
var value = Greeting.GetMessage(name);
|
||||
Assert.Equal(expect, value);
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
public class Greeting
|
||||
{
|
||||
public static string GetMessage(string name) {
|
||||
return String.Format("Hi {0}!", name);
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
var name = Environment.GetEnvironmentVariable("NAME");
|
||||
if (String.IsNullOrEmpty(name)) {
|
||||
name = "John Doe";
|
||||
}
|
||||
Console.Write(Greeting.GetMessage(name));
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<SelfContained>true</SelfContained>
|
||||
<RuntimeIdentifier>linux-musl-x64</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Greeting\Greeting.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@@ -0,0 +1,39 @@
|
||||
package dotnet
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet"
|
||||
"universe.dagger.io/docker"
|
||||
)
|
||||
|
||||
dagger.#Plan & {
|
||||
actions: test: {
|
||||
_source: dagger.#Scratch & {}
|
||||
|
||||
simple: {
|
||||
_image: dotnet.#Image & {}
|
||||
|
||||
verify: docker.#Run & {
|
||||
input: _image.output
|
||||
command: {
|
||||
name: "/bin/sh"
|
||||
args: ["-c", "dotnet --list-sdks | grep '6.0'"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
custom: {
|
||||
_image: dotnet.#Image & {
|
||||
version: "5.0"
|
||||
}
|
||||
|
||||
verify: docker.#Run & {
|
||||
input: _image.output
|
||||
command: {
|
||||
name: "/bin/sh"
|
||||
args: ["-c", "dotnet --list-sdks | grep '5.0'"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
package dotnet
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/dagger/core"
|
||||
"universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet"
|
||||
"universe.dagger.io/docker"
|
||||
"universe.dagger.io/alpine"
|
||||
)
|
||||
|
||||
dagger.#Plan & {
|
||||
client: filesystem: "./data": read: contents: dagger.#FS
|
||||
|
||||
actions: test: {
|
||||
_baseImage: {
|
||||
build: alpine.#Build & {
|
||||
packages: {
|
||||
"ca-certificates": {}
|
||||
"krb5-libs": {}
|
||||
libgcc: {}
|
||||
libintl: {}
|
||||
"libssl1.1": {}
|
||||
"libstdc++": {}
|
||||
zlib: {}
|
||||
}
|
||||
}
|
||||
output: build.output
|
||||
}
|
||||
|
||||
simple: {
|
||||
publish: dotnet.#Publish & {
|
||||
source: client.filesystem."./data".read.contents
|
||||
package: "hello"
|
||||
}
|
||||
|
||||
exec: docker.#Run & {
|
||||
input: _baseImage.output
|
||||
command: {
|
||||
name: "/bin/sh"
|
||||
args: ["-c", "/app/hello >> /output.txt"]
|
||||
}
|
||||
env: NAME: "dagger"
|
||||
mounts: binary: {
|
||||
dest: "/app"
|
||||
contents: publish.output
|
||||
source: "/"
|
||||
}
|
||||
}
|
||||
|
||||
verify: core.#ReadFile & {
|
||||
input: exec.output.rootfs
|
||||
path: "/output.txt"
|
||||
} & {
|
||||
contents: "Hi dagger!"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
setup() {
|
||||
load '../../../../bats_helpers'
|
||||
|
||||
common_setup
|
||||
}
|
||||
|
||||
@test "dotnet" {
|
||||
dagger "do" -p ./publish.cue test
|
||||
dagger "do" -p ./image.cue test
|
||||
dagger "do" -p ./test.cue test
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package dotnet
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet"
|
||||
)
|
||||
|
||||
dagger.#Plan & {
|
||||
client: filesystem: "./data": read: contents: dagger.#FS
|
||||
|
||||
actions: test: dotnet.#Test & {
|
||||
source: client.filesystem."./data".read.contents
|
||||
package: "./Greeting.Tests"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user