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

MSBuild --no-restore cli argument is not available despite a DoRestore option #2226

Closed
Danl2620 opened this issue Dec 14, 2018 · 5 comments · Fixed by #2250
Closed

MSBuild --no-restore cli argument is not available despite a DoRestore option #2226

Danl2620 opened this issue Dec 14, 2018 · 5 comments · Fixed by #2250

Comments

@Danl2620
Copy link

Description

Using the DotNet.build or DotNet.build it is not possible to pass through the --no-restore flag, despite the MSBuild.CliArguments type having a DoRestore member.

Repro steps

Create a build target like so:

Target.create "Build" (fun _ ->
    !! "TestProject 
    |> DotNet.publish (fun (info:DotNet.PublishOptions) -> 
        { info with
            MSBuildParams = { 
                MSBuild.CliArguments.Create() with 
                    DoRestore = false
            }
        })
)

Expected behavior

The build process would not do a restore before building.

Actual behavior

The build process does a restore.

Known workarounds

None that I am aware of.

Related information

  • Operating system: macOS
  • .NET Runtime, CoreCLR or Mono Version: .netcore 2.1
  • Version of FAKE (4.X, 5.X): 5.11.1
  • (if performance issue) Performance information, links to performance testing scripts: slow builds when doing quick local iteration.
@sliepie
Copy link
Contributor

sliepie commented Dec 14, 2018

You can set it as a MSBuild param. Thats the way I use it

@Danl2620
Copy link
Author

Can you give an example? I'm not seeing a way in the source...

@matthid
Copy link
Member

matthid commented Dec 15, 2018

I think this particular edge case is a bit of a pain.
Afaik when using the msbuild cli then --no-restore is the default and you need to use /restore to enable restore.
When using the dotnet cli its exactly the reverse. It will use /restore by default and skip it if --no-restore is given.
Therefore, I feel like we need to add --no-restore to the dotnet cli instead of adding it to MSBuildParams. We can either add it to DotNet.Options

https:/fsharp/FAKE/blob/bcbe8b3e1b772084b9cfb2667decd8e00b2fa35c/src/app/Fake.DotNet.Cli/DotNet.fs#L467-L487

But I don't think you can use --no-restore on all commands. Therefore it needs to be added to every command manually. We already have this for dotnet test but need to add it to others:

https:/fsharp/FAKE/blob/bcbe8b3e1b772084b9cfb2667decd8e00b2fa35c/src/app/Fake.DotNet.Cli/DotNet.fs#L1288-L1327

@matthid
Copy link
Member

matthid commented Dec 15, 2018

By the way current way to do this is to use the Common.CustomParams field:

https:/fsharp/FAKE/blob/bcbe8b3e1b772084b9cfb2667decd8e00b2fa35c/src/app/Fake.DotNet.Cli/DotNet.fs#L539-L544

@Danl2620
Copy link
Author

Thanks! I used withCustomParams and my particular case is solved:

Target.create "Build" (fun _ ->
    !! "TestProject 
    |> DotNet.publish (fun (info:DotNet.PublishOptions) -> 
        { info with
            Common = DotNet.Options.withCustomParams ("--no-restore" |> Some) info.Common
        })
)

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

Successfully merging a pull request may close this issue.

3 participants