-
Notifications
You must be signed in to change notification settings - Fork 14
Initial ecosystem implementation for .NET/C#. #3698
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
Conversation
|
||
func (e *DotNet) Init(runtimePath string, buildplan *buildplan.BuildPlan) error { | ||
e.runtimePath = runtimePath | ||
e.nupkgDir = filepath.Join("usr", "nupkg") |
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 default .NET package registry lives in the user's ~/.nuget/packages/ directory. We can override this with the $NUGET_PACKAGES
environment variable, and we'll point it to this directory: /usr/nupkg/.
8e3423d
to
39ab7d0
Compare
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.
Looks ok to me, one minor nit.
if file.Name() == "runtime.json" { | ||
err = injectEnvVar(file.AbsolutePath(), "NUGET_PACKAGES", "${INSTALLDIR}/"+e.nupkgDir) | ||
if err != nil { | ||
return nil, errs.Wrap(err, "Unable to add NUGET_PACKAGES to runtime.json") | ||
} | ||
continue | ||
} | ||
if !strings.HasSuffix(file.Name(), ".nupkg") { | ||
continue | ||
} |
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.
if file.Name() == "runtime.json" { | |
err = injectEnvVar(file.AbsolutePath(), "NUGET_PACKAGES", "${INSTALLDIR}/"+e.nupkgDir) | |
if err != nil { | |
return nil, errs.Wrap(err, "Unable to add NUGET_PACKAGES to runtime.json") | |
} | |
continue | |
} | |
if !strings.HasSuffix(file.Name(), ".nupkg") { | |
continue | |
} | |
if !strings.HasSuffix(file.Name(), ".nupkg") { | |
continue | |
} | |
if file.Name() == "runtime.json" { | |
err = injectEnvVar(file.AbsolutePath(), "NUGET_PACKAGES", "${INSTALLDIR}/"+e.nupkgDir) | |
if err != nil { | |
return nil, errs.Wrap(err, "Unable to add NUGET_PACKAGES to runtime.json") | |
} | |
continue | |
} |
Reduce chance for failures.
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.
Actually, that will prevent a runtime.json file from ever being processed. If there wasn't a !
, then I'd agree with your proposed changes.
The
dotnet
command, provided by the .NET runtime/SDK, functions likenpm
for JavaScript. It replaces nuget's functionality. (This means it is possible to usedotnet
to pull down packages from the nuget online package registry.) We cannot use nuget in Linux because of it's dependency on Mono, which is a large framework we should absolutely not depend on.However,
dotnet
requires a project to operate in, so we cannot install *.nupkg artifacts directly like we can with npm. Instead, we unpack *.nupkg artifacts into a directory structuredotnet
recognizes. Then users can build their own projects using our packages.The order of operations is:
$NUGET_PACKAGES
environment variable that points to our virtual environment's package listing.dotnet restore
, which will read your .NET project's project file and verify you have all the required dependencies (which should be in our virtual environment).After the
state install
command, I turned off my network to confirm thatdotnet
can detect and use packages in our virtual environment.It's a bit unfortunate that
dotnet restore
needs the--source $NUGET_PACKAGES
argument, but oh well. It's certainly possible that people building against a local package listing have to do something similar to prevent a reachout to the nuget registry, so it may not be so bad.