-
Notifications
You must be signed in to change notification settings - Fork 238
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
Use and forward additional nuget arguments #263
Conversation
Excellent. Thank you. Answering your questions:
|
Sure. I'll start to play around getting the current valid NuGet.confg and create a new pull request when I've the feeling that it is worth to do so ;-) |
Triggered by PR #263: Use and forward additional nuget arguments
I had a chance to look at the code and did some investigations. First question is, where to copy the config files. How about: internal static string CreateProject(CompilerParameters options, string[] fileNames, string outDir = null) And here I would add a method like that (untested): public void PrepareNuget(string scriptFile, string projectFile)
{
string nugetConfig = "NuGet.config";
string packagesConfig = "packages.config";
string scriptDirectorySource = scriptFile.GetDirName();
string scriptDirectoryDestination = projectFile.GetDirName();
string scriptPackageConfigSource = scriptDirectorySource.PathJoin(packagesConfig);
string scriptPackageConfigDestination = scriptDirectoryDestination.PathJoin(packagesConfig;
string scriptNugetConfigDestination = scriptDirectoryDestination.PathJoin(nugetConfig);
if (File.Exists(scriptPackageConfigSource))
{
File.Copy(scriptPackageConfigSource, scriptPackageConfigDestination);
}
DirectoryInfo directoryInfo = new DirectoryInfo(scriptDirectorySource);
while (directoryInfo != null)
{
string currentNuGetConfig = directoryInfo.FullName.PathJoin(nugetConfig);
if (File.Exists(currentNuGetConfig))
{
File.Copy(currentNuGetConfig, scriptNugetConfigDestination);
break;
}
// Look in parent directory
directoryInfo = directoryInfo.Parent;
}
} What do you think? Edit: I forgot to mention that the copy must take place before calling public string[] Resolve(string[] packages, bool suppressDownloading, string script) But at that point the project / build directory is not there since it will be created in |
I agree with your approach. all good. But I will need to check if the will keep you informed. X-mass break will give me some time for playing around :) |
After some further investigation I found that there are limit on what can be done with respect to consistency of "both scenarios, The reason for this is that Interestingly enough Visual Studio is also moving away from the config files. Thus my experiments with VS2022 showed that even of the IDE setting are defaulting the use of So this is what I have done for the next release of CS-Script (targeting .NET 6) that I am working on:
|
- Added .NET6 support - Issue #271: Any Special considerations running in a linux docker container? - Added support for `packages.config` and `NuGet.config` Triggered by PR #263: Use and forward additional nuget arguments - Various changes for .NET 6 porting - Create NuGetCache directory on environments without an existing package directory - Open main script in Visual Studio when project is loaded - PR #265: Do not overwrite return code set in Environment.ExitCode - Issue #264: Spelling issue? - Issue #260: Double Entry Point Definition
Hi Oleg,
I've an use case which needs to specify a personal nuget / artifactory respository. Therefore I tried to add the source with:
//css_nuget -ng:"-s https://artifactory.mydomain.com/artifactory/api/nuget/my-nuget-provider" CS-Script
Unfortunately that didn't work out very well. During debugging I discovered that
nugetArgs
set bystring nugetArgs = packageArgs.ArgValue("-ng");
is not used or forwarded toInstallPackage
. This patch fixes that one.In addition two other things came to my mind:
When I call the script by
cscs myScript.cs
the nuget packages will be downloaded. However, the script fails whencss -vs myScript.cs
is called and the local nuget cache is empty. It seems thatbool suppressDownloading
is set withvar refPkAsms = this.ResolvePackages(true); //suppressDownloading
but I've no idea why we need this flag.My script I've written is placed in a git repository which has it's own NuGet.config. This configuration defines also my private artifactory. So the assumption was originally that the script is this configuration too, since it is placed in a parent directory. But the generated project is placed in
%temp%
. I could be a good idea to copy the NuGet.config to the%temp
directory together with the temporarybuild.csproj
.So far,
Florian