Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve C# init behaviour for Github Package Registry #497

Merged
merged 1 commit into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions packages/cdktf-cli/templates/csharp/.hooks.sscaff.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,25 @@ exports.post = options => {
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>`, 'utf-8');
} else {
writeFileSync('./NuGet.Config', `<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="github" value="https://nuget.pkg.github.com/hashicorp/index.json" />
</packageSources>
<packageSourceCredentials>
<github>
<add key="Username" value="%GITHUB_USER%" />
<add key="ClearTextPassword" value="%GITHUB_TOKEN%" />
</github>
</packageSourceCredentials>
</configuration>`, 'utf-8');
}

execSync(`dotnet restore`, { stdio: 'inherit' });
// execSync(`dotnet restore`, { stdio: 'inherit' });
skorfmann marked this conversation as resolved.
Show resolved Hide resolved

execSync(`\"${process.execPath}\" ${cli} get`, { stdio: 'inherit' });
execSync(`\"${process.execPath}\" ${cli} synth`, { stdio: 'inherit' });
// execSync(`\"${process.execPath}\" ${cli} synth`, { stdio: 'inherit' });

console.log(readFileSync('./help', 'utf-8'));
};
Expand All @@ -59,4 +72,4 @@ function terraformCloudConfig(baseName, organizationName, workspaceName) {
new RemoteBackend(stack, new RemoteBackendProps { Hostname = "app.terraform.io", Organization = "${organizationName}", Workspaces = new NamedRemoteWorkspace("${workspaceName}") });`);

writeFileSync('./Main.cs', result, 'utf-8');
}
}
11 changes: 10 additions & 1 deletion packages/cdktf-cli/templates/csharp/help
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@
Destroy:
cdktf destroy Destroy the given stack

========================================================================================================
========================================================================================================

Important:

Please make sure to sign in to the Github Package registry and set your credentials in the Nuget.Config file which was generated.
You can find more info about setting up the Github Package registry here: https://cdk.tf/github-nuget

Then run "dotnet restore" to install the dependencies.

This is a temporary solution. We'll be publishing to the official nuget.org registry soon.
2 changes: 2 additions & 0 deletions test/test-csharp-app/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ process.chdir(folder);
// initialize an empty project
execSync(`cdktf init --template csharp --project-name="csharp-test" --project-description="csharp test app" --local`, { stdio: 'inherit', env });

execSync(`dotnet restore`)
skorfmann marked this conversation as resolved.
Show resolved Hide resolved

// put some code in it
fs.copyFileSync(path.join(scriptdir, 'Main.cs'), 'Main.cs');
fs.copyFileSync(path.join(scriptdir, 'cdktf.json'), 'cdktf.json');
Expand Down