Reputation: 199
I'm trying to work with Microsoft's Graph API at my company, and I'm following the online documentation to get this done. I'm working in VB .NET and I am importing the Microsoft.Graph.Auth package as it says, and when I build the code, I get the error above. Please see screenshot below too.
I'm unable to find a solution for this online. I cannot tell if it's something to do with the fact that it's a preview package? It's strange since this is what Microsoft instructs us to do...
Imports Microsoft.Identity.Client
Imports Microsoft.Graph
Imports Microsoft.Graph.Auth
Public Class Graph
Private clientId As String = System.Configuration.ConfigurationManager.AppSettings("GraphClientId")
Private redirectUri As String = System.Configuration.ConfigurationManager.AppSettings("RedirectUri")
Shared tenantID As String = System.Configuration.ConfigurationManager.AppSettings("GraphTenant")
Private clientSecret As String = System.Configuration.ConfigurationManager.AppSettings("GraphSecret")
Public authProvider As ClientCredentialProvider = Nothing
Public Sub Initialize()
Dim confidentialClientApplication As IConfidentialClientApplication = ConfidentialClientApplicationBuilder.Create(clientId).WithTenantId(tenantID).WithClientSecret(clientSecret).Build()
authProvider = New ClientCredentialProvider(confidentialClientApplication)
End Sub
Public Sub GetAllUserTasks()
Initialize()
Dim graphClient As New GraphServiceClient(authProvider)
Dim tasks = graphClient.[Me].Planner.Tasks.Request().GetAsync()
Debug.Print(tasks.Result.Item(0).Title)
End Sub
End Class
Would greatly appreciate the help!
Upvotes: 1
Views: 2536
Reputation: 3704
I was getting the same type of error, I was to resolve it by removing these tags in my .csproj files
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
Credit & additional details: Missing file NuGet.targets on existing project
Upvotes: 0
Reputation: 231
What version of nuget.exe are you using? You can get the version number by executing . C:\cps2\.nuget\NuGet.exe
in a console window.
If the version number is lower than 4.3.0, then download the latest version from https://www.nuget.org/downloads, and replace the current C:\cps2\.nuget\NuGet.exe
with the new one. This is because Microsoft.Graph.Auth uses SemVer v2.0.0 which is not compatible with NuGet clients older than 4.3.0. This is documented here https://learn.microsoft.com/en-us/nuget/concepts/package-versioning#semantic-versioning-200.
Upvotes: 6