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

Option --no-cache don't work as expected #580

Open
vitaliy-orlov opened this issue Sep 18, 2020 · 6 comments
Open

Option --no-cache don't work as expected #580

vitaliy-orlov opened this issue Sep 18, 2020 · 6 comments

Comments

@vitaliy-orlov
Copy link

Hello!
Version:

dotnet-script --help
0.53.0

Usage:  [arguments] [options] [command]

Command:

dotnet-script custom.csx -d --no-cache
dbug: Dotnet.Script.Core.Commands.ExecuteScriptCommand[0]
      The script /mnt/c/work/projects/test-project/custom.csx was executed with the '--no-cache' flag. Skipping cache.
info: Dotnet.Script.Core.ScriptCompiler[0]
      Current runtime is 'linux'.
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
      Creating project file for /mnt/c/work/projects/test-project/custom.csx
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptParser[0]
      Parsing /mnt/c/work/projects/test-project/custom.csx
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
      Project file saved to /root/.cache/dotnet-script/mnt/c/work/projects/test-project/netcoreapp3.1/script.csproj
dbug: Dotnet.Script.DependencyModel.ProjectSystem.ScriptProjectProvider[0]
      <?xml version="1.0" encoding="utf-8"?>
      <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
          <OutputType>Exe</OutputType>
          <TargetFramework>netcoreapp3.1</TargetFramework>
          <LangVersion>latest</LangVersion>
        </PropertyGroup>
        <ItemGroup>
          <PackageReference Include="MyNuget.Generators.Common" Version="1.0.2-rc1" />
          <PackageReference Include="MyNuget.Generator.MsSql" Version="1.0.0" />
        </ItemGroup>
        <Target Name="RecordReferencePaths" AfterTargets="AfterResolveReferences">
          <WriteLinesToFile File="$(OutputPath)/ReferencePaths.txt" Lines="@(ReferencePath)" />
        </Target>
      </Project>
dbug: Dotnet.Script.DependencyModel.Context.DotnetRestorer[0]
      Restoring /root/.cache/dotnet-script/mnt/c/work/projects/test-project/netcoreapp3.1/script.csproj using the dotnet cli. RuntimeIdentifier : linux-x64 NugetConfigFile: /root/.nuget/NuGet/NuGet.Config
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      Executing 'dotnet restore "/root/.cache/dotnet-script/mnt/c/work/projects/test-project/netcoreapp3.1/script.csproj" -r linux-x64  --configfile "/root/.nuget/NuGet/NuGet.Config"'
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
        Determining projects to restore...
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      /root/.cache/dotnet-script/mnt/c/work/projects/test-project/netcoreapp3.1/script.csproj : error NU1102: Unable to find package MyNuget.Generators.Common with version (>= 1.0.2-rc1)
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
      /root/.cache/dotnet-script/mnt/c/work/projects/test-project/netcoreapp3.1/script.csproj : error NU1102:   - Found 4 version(s) in nexus [ Nearest version: 1.0.1 ]
dbug: Dotnet.Script.DependencyModel.Process.CommandRunner[0]
        Failed to restore /root/.cache/dotnet-script/mnt/c/work/projects/test-project/netcoreapp3.1/script.csproj (in 445 ms).
System.Exception: Unable to restore packages from '/root/.cache/dotnet-script/mnt/c/work/projects/test-project/netcoreapp3.1/script.csproj'. Make sure that all script files contains valid NuGet references
   at Dotnet.Script.DependencyModel.Context.DotnetRestorer.Restore(ProjectFileInfo projectFileInfo, String[] packageSources) in D:\a\1\s\src\Dotnet.Script.DependencyModel\Context\DotnetRestorer.cs:line 52
   at Dotnet.Script.DependencyModel.Context.ProfiledRestorer.Restore(ProjectFileInfo projectFileInfo, String[] packageSources) in D:\a\1\s\src\Dotnet.Script.DependencyModel\Context\ProfiledRestorer.cs:line 24
   at Dotnet.Script.DependencyModel.Runtime.RuntimeDependencyResolver.GetDependencies(String scriptFile, String[] packageSources) in D:\a\1\s\src\Dotnet.Script.DependencyModel\Runtime\RuntimeDependencyResolver.cs:line 48
   at Dotnet.Script.Core.ScriptCompiler.GetRuntimeDependencies(ScriptContext context) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\ScriptCompiler.cs:line 167
   at Dotnet.Script.Core.ScriptCompiler.CreateCompilationContext[TReturn,THost](ScriptContext context) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\ScriptCompiler.cs:line 128
   at Dotnet.Script.Core.ScriptEmitter.Emit[TReturn,THost](ScriptContext context) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\ScriptEmitter.cs:line 23
   at Dotnet.Script.Core.ScriptPublisher.CreateScriptAssembly[TReturn,THost](ScriptContext context, String outputDirectory, String assemblyFileName) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\ScriptPublisher.cs:line 103
   at Dotnet.Script.Core.ScriptPublisher.CreateAssembly[TReturn,THost](ScriptContext context, LogFactory logFactory, String assemblyFileName) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\ScriptPublisher.cs:line 47
   at Dotnet.Script.Core.Commands.PublishCommand.Execute(PublishCommandOptions options) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\Commands\PublishCommand.cs:line 45
   at Dotnet.Script.Core.Commands.ExecuteScriptCommand.<GetLibrary>g__CreateLibrary|6_0(<>c__DisplayClass6_0& ) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\Commands\ExecuteScriptCommand.cs:line 68
   at Dotnet.Script.Core.Commands.ExecuteScriptCommand.GetLibrary(ExecuteScriptCommandOptions executeOptions) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\Commands\ExecuteScriptCommand.cs:line 62
   at Dotnet.Script.Core.Commands.ExecuteScriptCommand.Run[TReturn,THost](ExecuteScriptCommandOptions options) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script.Core\Commands\ExecuteScriptCommand.cs:line 34
   at Dotnet.Script.Program.<>c__DisplayClass4_0.<<Wain>b__9>d.MoveNext() in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script\Program.cs:line 242
--- End of stack trace from previous location where exception was thrown ---
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass126_0.<OnExecute>b__0() in C:\projects\commandlineutils\src\CommandLineUtils\CommandLineApplication.cs:line 505
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) in C:\projects\commandlineutils\src\CommandLineUtils\CommandLineApplication.cs:line 611
   at Dotnet.Script.Program.Wain(String[] args) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script\Program.cs:line 251
   at Dotnet.Script.Program.Main(String[] args) in C:\Users\VssAdministrator\AppData\Local\Temp\tmp5FE\Dotnet.Script\Program.cs:line 27

I expected to see --no-cache argument inside command dotnet restore , but i don't see it here - Executing 'dotnet restore "/root/.cache/dotnet-script/mnt/c/work/projects/test-project/netcoreapp3.1/script.csproj" -r linux-x64 --configfile "/root/.nuget/NuGet/NuGet.Config"'

I don't have any local errors if run command dotnet restore --no-cache /root/.cache/dotnet-script/mnt/c/work/projects/test-project/netcoreapp3.1/script.csproj

Does it work as disigned or does it a bug?

@filipw
Copy link
Member

filipw commented Sep 18, 2020

it is a bug. The no-cache option was intended to bypass dotnet-script cache (forces a full recompile and dependency restore) but your scenario to be able o force an update of the package used by dotnet restore makes sense here too.

@seesharper
Copy link
Collaborator

The --no-cache option means that we don't cache anything related to the script execution and compilation. We currently don't pass that down to dotnet restore, but maybe we should?

@filipw
Copy link
Member

filipw commented Sep 18, 2020

I am not convinced, perhaps it needs a separate flag, something like --no-restore-cache because otherwise it could make --no-cache terribly slow, if you want to bypass script compilation it doesn't automatically mean you need to opt-into downloading 30MB of .NET Core dependencies

@seesharper
Copy link
Collaborator

I agree. It should be a separate flag indeed

@vitaliy-orlov
Copy link
Author

vitaliy-orlov commented Sep 18, 2020

Cool! I'll be waiting for the new flag then :)

@mungojam
Copy link

This might help with a problem I have seen where the script won't run after I run dotnet nuget locals all clear until I manually run dotnet restore in the compiled script dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants