Why do we have to "Specify the Web SDK in the project file" when doing integration tests in ASP.NET Core? #49601
-
On the Test app prerequisites section of the
I couldn't find anywhere information about why we need to "specify Web SDK in the project file" ? I'm just curious about this as I can also get integration tests to run whilst leaving the SDK set to |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
The reference means that some MSBuild targets will be pulled in that will copy files needed by things such as MVC and Razor Pages if you're doing UI tests (I think there's some other use cases too, but I forget what they are right now). I would imagine that it was easier for the document to be written with "add this one line" rather than "add this one line if you do any of these X use cases". If you remove it and your tests all still pass then I don't think there's any harm in you leaving it out, but for the sake of one line and potential future confusion it's probably best just to add it so things should "Just Work ™️" as your application and tests evolve over time. |
Beta Was this translation helpful? Give feedback.
-
Thanks, I was wondering what those edge cases would be where it is absolutely required. I do agree that:
However, the side effect is dealing with things like a It would probably help if that part of the documentation was clearer on when you need to change the SDK in the project file. And I also think that adding a note about the @martincostello, thank you for your reply. If possible, I'd like to get better clarification on :
So, I'm going to leave this question open for now, hoping someone can better detail what are the pros/cons to using |
Beta Was this translation helpful? Give feedback.
-
I think it is mostly because of the default references and global usings that come with the sdk. Technically it is not necessary and personally I avoid it. |
Beta Was this translation helpful? Give feedback.
The reference means that some MSBuild targets will be pulled in that will copy files needed by things such as MVC and Razor Pages if you're doing UI tests (I think there's some other use cases too, but I forget what they are right now).
I would imagine that it was easier for the document to be written with "add this one line" rather than "add this one line if you do any of these X use cases".
If you remove it and your tests all still pass then I don't think there's any harm in you leaving it out, but for the sake of one line and potential future confusion it's probably best just to add it so things should "Just Work ™️" as your application and tests evolve over time.