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

Weird Visual Studio behavior on non-packable projects #16

Closed
rdeago opened this issue May 20, 2022 · 1 comment
Closed

Weird Visual Studio behavior on non-packable projects #16

rdeago opened this issue May 20, 2022 · 1 comment
Labels

Comments

@rdeago
Copy link

rdeago commented May 20, 2022

Describe the Bug

A simple library project targeting .NET Standard 2.0 and not meant to be packaged, therefore not setting the PackageId property, must set the IsPackable property to false, despite what's stated in Directory.Build.Targets:

    <!-- The Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets unconditionally sets 
        PackageId=AssemblyName if no PackageId is provided, and then defaults IsPackable=true if 
        a PackageId is set (?!), meaning that by default everything is packable in Sdk-style 
        projects. 
        The Directory.Build.targets are imported after the user's project properties have been 
        read, and therefore gives us a chance to inspect if an explicit PackageId was provided, 
        before the NuGet SDK target is imported and defaults it. At this point, we can give 
        IsPackable a more sensible default, making it false if no PackageId was provided at this 
        point. -->

If IsPackable is not set to anything in the project file, Visual Studio will go into an infinite loop, triggering a design-time build of the project approximately every 2 seconds.

From what I have observed, the evaluated value of IsPackable in these design-time builds alternates between true and false (true in one build, false in the following one, repeat ad libitum).

Steps to Reproduce

Create a new Library project. No code necessary. Do not set IsPackable. Watch Visual Studio go crazy.

Expected Behavior

Visual Studio should not repeatedly trigger design-time builds for no reason.

Version Info

Bug observed adding a project to https://github.com/devlooped/ThisAssembly v1.0.9, using VS2022 v17.2.1

Additional Info

@rdeago rdeago added the bug label May 20, 2022
@kzu
Copy link
Member

kzu commented Aug 5, 2022

Seems to be only triggered when the version is dynamic, no? Because these targets set these locally to a hardcoded 42.42.42 value 🤔 . I'm puzzled since I looked at the SDK targets in order to add this, and I never experienced this issue myself, and in all projects I use these targets in, I never set IsPackable (i.e. a trivial one at https://github.com/devlooped/web/blob/main/src/Tests/Tests.csproj).

@kzu kzu added question and removed bug labels Aug 5, 2022
@kzu kzu closed this as not planned Won't fix, can't repro, duplicate, stale Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants