Azure / azure-functions-vs-build-sdk

MSBuild task for Azure Functions
MIT License
95 stars 64 forks source link

Prevent accidentally updating v3 app to use v4 SDK #533

Open anthonychu opened 2 years ago

anthonychu commented 2 years ago

We should consider this before we take teh v4 SDK out of preview.

/cc @soninaren

ChristopherL-STCU commented 2 years ago

I just experienced this so it would have been helpful

anthonychu commented 2 years ago

@ChristopherL-STCU This version only targets net6.0. How did you update the package? Were you able to compile the app after upgrade?

ChristopherL-STCU commented 2 years ago

Dependabot suggested the upgrade. I went back to Visual Studio and pulled up the UI for the NuGet package manager. It also showed the upgrade and so I upgraded. It did not compile afterwards, hence how I ended up here. After upgrading VS showed Microsoft.Azure.WebJobs.Extensions.Http as no longer being used and showed compile errors for the Function Http Trigger Attributes.

coder-candace commented 2 years ago

I too experienced the same issue as @ChristopherL-STCU and I had the following errors image Downgrading back to v3.0.13 fixed the issue.

SteffenLG commented 2 years ago

I also had trouble with this. In Visual Studio's Nuget Package Manager window I noticed a suggested update, so I applied it. This resulted in the following mess: image I tried a few things like restarting Visual Studio, cleaning and rebuilding etc to no avail, and ended up using git restore to roll it back.

anthonychu commented 2 years ago

@vijayrkn Do you know how we can prevent the VS NuGet UI from upgrading v3 apps to an incompatible SDK version?

vijayrkn commented 2 years ago

@anthonychu - All these packages are targeting netstandard2.0 - https://github.com/Azure/azure-functions-dotnet-worker/blob/648473e4c770ec7b2f3703bd18e883b4650a91c6/build/Extensions.props#L4

That is why NuGet is suggesting them as applicable for all TFMs. If specific package versions would only work against a specific TFM, the right thing would be to target the package for that TFM.

image

raymens commented 2 years ago

https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions/4.0.1 is only mentioning net6.0 dependencies. However VS (both 2019 and 2022) will allow you to update anyway, it just removes all the older dependencies. This is for a netcoreapp3.1 project.

So it looks like VS treats it a dependencies, instead of requirements.

image