-
Notifications
You must be signed in to change notification settings - Fork 757
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
msbuild task and cli nugets #1992
Conversation
@@ -77,6 +77,109 @@ stages: | |||
official: ${{ parameters.official }} | |||
rid: osx-x64 | |||
|
|||
- job: packages_windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages_windows [](start = 9, length = 16)
Packages have to be signed on a Windows container (limitations of the current infra), but tests have to run on the right OS as separate jobs. This is different than the GH build.
rid: win-x64 | ||
artifactSuffix: windows | ||
|
||
- job: packages_test_linux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages_test_linux [](start = 9, length = 19)
Sadly no osx image in the internal pipeline, which means no E2E tests :( We do have them on the GH side, though.
@@ -0,0 +1,42 @@ | |||
<# | |||
Prerequisites: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prerequisites [](start = 0, length = 13)
Same script as in the types-az repo.
@@ -19,4 +19,30 @@ | |||
<ItemGroup> | |||
<AdditionalFiles Include="$(MSBuildThisFileDirectory)/BannedSymbols.txt" /> | |||
</ItemGroup> | |||
|
|||
<!-- Nuget Publishing related properties that are common to all packages --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nuget [](start = 7, length = 5)
Copied from the types-az repo.
Prerequisites: | ||
- Copy bicep.exe and *.pdb from Bicep CLI publish directory to bicep\ directory under this project. | ||
--> | ||
<Project Sdk="Microsoft.Build.NoTargets"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NoTargets [](start = 30, length = 9)
This is a completely custom NuGet without a real assembly, so I had to do it myself in a NoTargets SDK project :( Thankfully NuGet.exe is available in a NuGet package and works on all the major OSs.
<!-- | ||
This project prevents the e2e tests from inheriting our repo build settings. | ||
--> | ||
<Project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Project [](start = 1, length = 7)
The e2e tests for the msbuild task involve calling msbuild to build test projects. The files in this directory isolate the test builds from our normal settings.
Pickup latest available packages (including prerelease) from local feed configured in NuGet.config. | ||
--> | ||
<ItemGroup> | ||
<PackageReference Include="Azure.Bicep.CommandLine.$(RuntimeSuffix)" Version="*-*" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [](start = 82, length = 3)
This is not ok to use in a normal project, but for test purposes it's a great way of picking up the latest package from the local feed.
<packageSources> | ||
<clear /> | ||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> | ||
<add key="Local" value="local-packages" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local-packages [](start = 28, length = 14)
The GH and ADO build is setup to drop packages here when they are built, so the project will use newest package from the build.
@@ -0,0 +1,15 @@ | |||
{ | |||
"compilerOptions": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compilerOptions [](start = 5, length = 15)
I mostly set up the e2e project by copy/pasting existing things. @shenglol and @anthony-c-martin, I haven't done a whole lot of TS, so feel free to point out any weirdness.
"@types/jest": "^26.0.21", | ||
"cross-spawn": "^7.0.3", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.2.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using prettier in this project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am now :)
const projectDir = path.normalize(path.join(__dirname, `../examples/${projectName}/`)) | ||
this.projectDir = projectDir, | ||
this.projectFile = path.join(projectDir, `${projectName}.proj`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] missing semicolons and indenting. Prettier would probably catch this if you feel like enabling it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by auto formatting.
encoding: "utf-8", | ||
}); | ||
|
||
if(expectSuccess && result.status != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convention is to use ===
and !==
by default unless you've got very good reasons not to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a bit late for this - but is packaging architecture-agnostic managed DLLs an option?
e.g. invoking it via:
dotnet ./src/Bicep.Cli/bin/Debug/net5.0/bicep.dll --help
We'd need a check for dotnet >= 5 somehow (or could perhaps pull it down via nuget); which may or may not be an option for internal MSFT builds.
That was the initial approach I wanted to go with, but users with locked down pipelines do not always control which runtimes are installed on the build agents. I think in the future we can add a platform-agnostic version of the CLI nuget and update the MSBuild nuget to call dotnet
on it, but the current CLI nugets will need to remain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above reply went to the wrong comment, but fixed the wrong operator also.
public clean() { | ||
const result = spawn.sync("git", ["clean", "-dfx", "--", this.projectDir], { | ||
cwd: this.projectDir, | ||
stdio: "pipe", | ||
encoding: "utf-8", | ||
}); | ||
|
||
if(result.status != 0) { | ||
this.handleFailure("git", result); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had an issue raised about having an implicit dependency on git in our build process; might be nice to avoid this if possible - for example by staging files to a temp directory.
https://www.npmjs.com/package/nodegit is a potential solution, but I personally hate it - on some platforms it has to compile git from source which takes AGES
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I remember that, but it's rather difficult to get all the dependencies lined up to even run these tests correctly. We can fix once we get feedback.
@@ -0,0 +1,9 @@ | |||
root = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth just adding this to the top-level .editorconfig
for [*.{ts,tsx,js}]
rather than creating new ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good pt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Might be a bit late for this - but is packaging architecture-agnostic managed DLLs an option? e.g. invoking it via: We'd need a check for dotnet >= 5 somehow (or could perhaps pull it down via nuget); which may or may not be an option for internal MSFT builds. |
import * as spawn from 'cross-spawn'; | ||
import * as path from "path"; | ||
import * as fs from "fs"; | ||
import { SpawnSyncReturns } from 'node:child_process'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Inconsistent quotes. Formatting the document in VSCode will fix these automatically if you have the prettier extension installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by auto formatting.
@@ -0,0 +1,6 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by auto formatting.
@@ -0,0 +1,72 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by auto formatting.
Added:
This fixes #290.