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

NET SDK with Microsoft.VisualStudio.JavaScript.SDK dependency results in System.Text.Json - File not found through when specifying NET SDK Version #39152

Open
jonmeyerson opened this issue Mar 2, 2024 · 7 comments
Assignees
Labels
Area-esproj Issues related to the Javascript project system untriaged Request triage from a team member

Comments

@jonmeyerson
Copy link

jonmeyerson commented Mar 2, 2024

Describe the bug

Building a .NET 6 App that references a Microsoft.VisualStudio.JavaScript.SDK fails on Azure DevOps and produces an error indicating a missing dependency to System.Text.Json

Note: Deploying through Visual Studio 2022 Publish works as expected to Azure Resource.

To Reproduce

A simple project created following the guide here, https://learn.microsoft.com/en-us/visualstudio/javascript/tutorial-asp-net-core-with-vue?view=vs-2022

  1. Started a new project in VS 2022 of type "Vue and ASP.NET Core (Javascript)"
  2. Upgraded Microsoft.VisualStudio.JavaScript.SDK to 1.0.586930
  3. Changed Port in vite.config to match generated port in server. (step does not matter for build)
  4. Created .azureDevops folder with yaml for building the project.
  5. Imported yaml as a new pipeline and run the pipeline.

https://github.com/jonmeyerson/Microsoft.VisualStudio.JavaScript.Sdk-AzureDeploy

Exceptions (if any)

`Build FAILED.

   "D:\a\1\s\AzureDeploymentTest.sln" (Restore target) (1) ->
   "D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj" (_GenerateProjectRestoreGraph target) (3:6) ->
   (GeneratePackageJsonProps target) -> 
     C:\Users\VssAdministrator\.nuget\packages\microsoft.visualstudio.javascript.sdk\1.0.586930\Sdk\Sdk.targets(259,5): error MSB4018: The "GeneratePackageJsonProps" task failed unexpectedly. [D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj]
   C:\Users\VssAdministrator\.nuget\packages\microsoft.visualstudio.javascript.sdk\1.0.586930\Sdk\Sdk.targets(259,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. [D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj]
   C:\Users\VssAdministrator\.nuget\packages\microsoft.visualstudio.javascript.sdk\1.0.586930\Sdk\Sdk.targets(259,5): error MSB4018: File name: 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' [D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj]
   C:\Users\VssAdministrator\.nuget\packages\microsoft.visualstudio.javascript.sdk\1.0.586930\Sdk\Sdk.targets(259,5): error MSB4018:    at Microsoft.VisualStudio.JavaScript.Tasks.GeneratePackageJsonProps.Execute() [D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj]
   C:\Users\VssAdministrator\.nuget\packages\microsoft.visualstudio.javascript.sdk\1.0.586930\Sdk\Sdk.targets(259,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj]
   C:\Users\VssAdministrator\.nuget\packages\microsoft.visualstudio.javascript.sdk\1.0.586930\Sdk\Sdk.targets(259,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj]

0 Warning(s)
1 Error(s)`

Further technical details

.NET SDK 6.0.419
Microsoft.VisualStudio.JavaScript.Sdk/1.0.586930
dev.azure.com - Azure Devops ( Version Dev19.M234.1 (AzureDevOps_M234_20240228.4) )

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-WebSDK untriaged Request triage from a team member labels Mar 2, 2024
@baronfel baronfel added Area-esproj Issues related to the Javascript project system and removed Area-WebSDK labels Mar 2, 2024
@baronfel
Copy link
Member

baronfel commented Mar 2, 2024

@joj here's another - I've made a new label called 'Area-esproj' for tickets related to the javascript project system. It would be great if your team could periodically check this label for untriaged items.

@jonmeyerson
Copy link
Author

jonmeyerson commented Mar 3, 2024

This was related to

  - task: UseDotNet@2
     inputs:
       packageType: 'sdk'
       version: '6.0.419'

after removing the explicit SDK version in the yaml pipeline, I followed the workaround here: #39148 and it build successfully.

Workaround branch:
https://github.com/jonmeyerson/Microsoft.VisualStudio.JavaScript.Sdk-AzureDeploy/tree/workaround

Also, i noticed if i did the build of the client app before setting the sdk version it worked, without #39148 - but then the build later on for server that references client would still have the issue.
Also, besides the dotnet task, having a global.json in the server project with

{
  "sdk": {
    "version": "6.0.419"
  }
}

Will also indicate the System.Text.Json is not found.

System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at Microsoft.VisualStudio.JavaScript.Tasks.GeneratePackageJsonProps.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
C:\Users\VssAdministrator\.nuget\packages\microsoft.visualstudio.javascript.sdk\1.0.586930\Sdk\Sdk.targets(259,5): error MSB4018: The "GeneratePackageJsonProps" task failed unexpectedly. [D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.visualstudio.javascript.sdk\1.0.586930\Sdk\Sdk.targets(259,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. [D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.visualstudio.javascript.sdk\1.0.586930\Sdk\Sdk.targets(259,5): error MSB4018: File name: 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' [D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.visualstudio.javascript.sdk\1.0.586930\Sdk\Sdk.targets(259,5): error MSB4018:    at Microsoft.VisualStudio.JavaScript.Tasks.GeneratePackageJsonProps.Execute() [D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.visualstudio.javascript.sdk\1.0.586930\Sdk\Sdk.targets(259,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.visualstudio.javascript.sdk\1.0.586930\Sdk\Sdk.targets(259,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [D:\a\1\s\azuredeploymenttest.client\azuredeploymenttest.client.esproj]


@jonmeyerson jonmeyerson changed the title Microsoft.VisualStudio.JavaScript.SDK Dependency on System.Text.Json - File not found through Azure Devops build NET SDK with Microsoft.VisualStudio.JavaScript.SDK dependency results in System.Text.Json - File not found through when specifying SDK Mar 4, 2024
@jonmeyerson jonmeyerson changed the title NET SDK with Microsoft.VisualStudio.JavaScript.SDK dependency results in System.Text.Json - File not found through when specifying SDK NET SDK with Microsoft.VisualStudio.JavaScript.SDK dependency results in System.Text.Json - File not found through when specifying NET SDK Version Mar 4, 2024
@lorenyaSICKAG
Copy link

I have the same problem/error, I don't understand the workaround? Can you explain how you got it to work?

@jonmeyerson
Copy link
Author

I have the same problem/error, I don't understand the workaround? Can you explain how you got it to work?

You can see the first branch here that has the issue, and the commit that fixes it.
jonmeyerson/Microsoft.VisualStudio.JavaScript.Sdk-AzureDeploy@d47af92

@lorenyaSICKAG
Copy link

lorenyaSICKAG commented May 23, 2024

Unfortunately I don't use Azure Pipelines, but an Dockerfile to build an image with the dotnet application. I only could fix it by upgrading to .NET 8. I don't know if it works with .NET 7 as well, but switching the SDK worked for me.
It seems that the .NET 6 SDK have a problem building an Docker image with the JavaScript SDK.

@Forgind
Copy link
Member

Forgind commented Jun 11, 2024

/cc: @joj

It sounds like this might be resolved in later versions. Can you triage this when you get the chance?

@Forgind Forgind assigned joj and unassigned Forgind Jun 11, 2024
@cuongwf1711
Copy link

I am facing a similar issue. Please help me and provide a solution.

f36ac5ab-e1b8-435c-9f94-f58dd214c3c2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-esproj Issues related to the Javascript project system untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

6 participants