Closed mesakomarevich closed 3 years ago
Given the updated testing that I have done, I believe that some change to either the dotnet restore
or MSBuild
version included with the Windows Server 2019 virtual environment
after version 20210516.0
are causing these build problems for us, either that dotnet restore
is not correctly restoring packages, or that MSBuild
is not correctly interpreting the packages restored with dotnet restore
.
@medyagh can you please extract the project configuration from your project, remove all the source code besides main.cs and dependencies?
Hello @mesakomarevich. Could you please provide us with a public simple repository containing minimal repro steps to speed up our investigation?
Hello @mesakomarevich. Do you have any updates on repro steps?
Hello @mesakomarevich. I'm going to close this issue. If you have any updates or questions feel free to reopen the issue.
Description
Our Azure Devops Pipeline started failing builds with the
Visual Studio Build
,MSBuild
, andMSIX build and package
tasks when attempting to build our .msixbundle installer project with the following error:`
[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\DesktopBridge\Microsoft.DesktopBridge.targets(16,3): Error MSB4019: The imported project "C:\hostedtoolcache\windows\dotnet\sdk\3.1.410\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.NuGet.targets" was not found. Confirm that the expression in the Import declaration "C:\hostedtoolcache\windows\dotnet\sdk\3.1.410\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.NuGet.targets" is correct, and that the file exists on disk.
`
The last change to our pipeline was several months ago, and we narrowed the issue down to a change in the virtual environment by running the unmodified pipeline on the last successful build (being our master branch), which then failed with the exact same
MSB4019
error as above.Our pipeline originally only used the
Visual Studio Build
task, but in our effort to debug the issue, we tried using theMSBuild
andMSIX build and package
tasks, both of which failed with the aboveMSB4019
error message.After some investigating I found that the
Sdk.NuGet.Targets
file existed in theC:\Program Files\dotnet\sdk\5.0.301\Sdks\Microsoft.NET.Sdk\Sdk
directory on my development machine, but not in theC:\Program Files\dotnet\sdk\3.1.410\Sdks\Microsoft.NET.Sdk\Sdk
directory. As such I changed ourUse .NET Core
task to install.NET 5.x
instead of.NET Core 3.x
. Doing this then caused a new error to occur when building the project:`
[error]C:\hostedtoolcache\windows\dotnet\sdk\5.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): Error NETSDK1004: Assets file 'D:\a\1\s\\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
`
Our
dotnet restore
task originally only had it'sPath to project(s)
field set with paths to the.csproj
files we were building, so I added the path to the installer project's.wapproj
. This resulted in no changes to theVisual Studio Build
task behavior, and failed again with the sameNETSDK1004
error.We were finally able to resolve this issue by making the following changes to the
Visual Studio Build
task:/t:Restore;Build
to our list ofMSBuild Arguments
Clean
parameterIn summary, the following changes were made to our pipeline to resolve this issue:
.NET 5.x
instead of.NET Core 3.x
.wapproj
project in ourdotnet restore
task/t:Restore;Build
to our list ofMSBuild Arguments
Clean
parameter of theVisual Studio Build
taskI have not yet had a chance to test which combination of the above four changes was necessary to fix our problem, but will provide updates if I find anything new.
Update: The following configuration fails with
NETSDK1004
:.NET 5.x
instead of.NET Core 3.x
.wapproj
project in ourdotnet restore
task/t:Restore;Build
to our list ofMSBuild Arguments
Clean
parameter of theVisual Studio Build
task\ \ The following configuration passes:
.NET 5.x
instead of.NET Core 3.x
.wapproj
project in ourdotnet restore
task (completely disabled thedotnet restore
task in this case)/t:Restore;Build
to our list ofMSBuild Arguments
Clean
parameter of theVisual Studio Build
task\ \ The following configuration fails with
NETSDK1004
:.NET 5.x
instead of.NET Core 3.x
.wapproj
project in ourdotnet restore
task/t:Restore;Build
to our list ofMSBuild Arguments
Clean
parameter of theVisual Studio Build
task\ \ The following configuration fails with
NETSDK1004
:.NET 5.x
instead of.NET Core 3.x
.wapproj
project in ourdotnet restore
task/t:Restore;Build
to our list ofMSBuild Arguments
Clean
parameter of theVisual Studio Build
task\ Area for Triage:
.NET Core
Question, Bug, or Feature?:
Bug
Virtual environments affected
Image version
All versions above 20210516.0
Expected behavior
The project to build without error as we have confirmed that the changes made in our new PRs was not causing the issue.
Actual behavior
The project fails to build, despite no changes being made to the pipeline, and running on code that previously built without issue.
Repro steps
Unfortunately, this is a private repo, so I cannot publicly share our logs or a public example.