1d215c2c0c
* Move InstallDependencies to the language plugin This changes `pulumi new` and `pulumi up <template>` to invoke the language plugin to install dependencies, rather than having the code to install dependencies hardcoded into the cli itself. This does not change the way policypacks or plugin dependencies are installed. In theory we can make pretty much the same change to just invoke the language plugin, but baby steps we don't need to make that change at the same time as this. We used to feed the result of these install commands (dotnet build, npm install, etc) directly through to the CLI stdout/stderr. To mostly maintain that behaviour the InstallDependencies gRCP method streams back bytes to be written to stdout/stderr, those bytes are either read from pipes or a pty that we run the install commands with. The use of a pty is controlled by the global colorisation option in the cli. An alternative designs was to use the Engine interface to Log the results of install commands. This renders very differently to just writing directly to the standard outputs and I don't think would support control codes so well. The design as is means that `npm install` for example is still able to display a progress bar and colors even though we're running it in a separate process and streaming its output back via gRPC. The only "oddity" I feel that's fallen out of this work is that InstallDependencies for python used to overwrite the virtualenv runtime option. It looks like this was because our templates don't bother setting that. Because InstallDependencies doesn't have the project file, and at any rate will be used for policy pack projects in the future, I've moved that logic into `pulumi new` when it mutates the other project file settings. I think we should at some point cleanup so the templates correctly indicate to use a venv, or maybe change python to assume a virtual env of "venv" if none is given? * Just warn if pty fails to open * Add tests and return real tty files * Add to CHANGELOG * lint * format * Test strings * Log pty opening for trace debugging * s/Hack/Workaround * Use termios * Tweak terminal test * lint * Fix windows build |
||
---|---|---|
.. | ||
Pulumi | ||
Pulumi.Automation | ||
Pulumi.Automation.Tests | ||
Pulumi.FSharp | ||
Pulumi.Tests | ||
cmd/pulumi-language-dotnet | ||
.editorconfig | ||
.gitignore | ||
Makefile | ||
README.md | ||
dotnet.sln | ||
dotnet.sln.DotSettings | ||
pulumi_logo_64x64.png |
README.md
.NET Language Provider
A .NET language provider for Pulumi.
Building and Running
To build, you'll want to install the .NET Core 3.0 SDK or greater, and ensure
dotnet
is on your path. Once that it does, running make
in either the root
directory or the sdk/dotnet
directory will build and install the language
plugin.
Once this is done you can write a Pulumi app written on top of .NET. You can find
many examples showing how this can be done with C#, F#, or VB.
Your application will need to reference the Pulumi NuGet package
or the Pulumi.dll
built above.
Here's a simple example of a Pulumi app written in C# that creates some simple AWS resources:
// Copyright 2016-2019, Pulumi Corporation
using System.Collections.Generic;
using System.Threading.Tasks;
using Pulumi;
using Pulumi.Aws.S3;
class Program
{
static Task<int> Main()
=> Deployment.RunAsync(() =>
{
var config = new Config("hello-dotnet");
var name = config.Require("name");
// Create the bucket, and make it public.
var bucket = new Bucket(name, new BucketArgs { Acl = "public-read" });
// Add some content.
var content = new BucketObject($"{name}-content", new BucketObjectArgs
{
Acl = "public-read",
Bucket = bucket.Id,
ContentType = "text/plain; charset=utf8",
Key = "hello.txt",
Source = new StringAsset("Made with ❤, Pulumi, and .NET"),
});
// Return some values that will become the Outputs of the stack.
return new Dictionary<string, object>
{
{ "hello", "world" },
{ "bucket-id", bucket.Id },
{ "content-id", content.Id },
{ "object-url", Output.Format($"http://{bucket.BucketDomainName}/{content.Key}") },
};
});
}
Make a Pulumi.yaml file:
$ cat Pulumi.yaml
name: hello-dotnet
runtime: dotnet
Then, configure it:
$ pulumi stack init hello-dotnet
$ pulumi config set name hello-dotnet
$ pulumi config set aws:region us-west-2
And finally, preview and update as you would any other Pulumi project.
Public API Changes
When making changes to the code you may get the following compilation error:
error RS0016: Symbol XYZ' is not part of the declared API.
This indicates a change in public API. If you are developing a change
and this is intentional, add the new API elements to
PublicAPI.Unshipped.txt
corresponding to your project (some IDEs
will do this automatically for you, but manual additions are fine as
well).
Project maintainers will move API elements from
PublicAPI.Unshipped.txt
to PublicAPI.Shipped.txt
when cutting a
release.