microsoft / service-fabric

Service Fabric is a distributed systems platform for packaging, deploying, and managing stateless and stateful distributed applications and containers at large scale.
https://docs.microsoft.com/en-us/azure/service-fabric/
MIT License
3.03k stars 399 forks source link

The "GetServiceProjectReferences" task failed unexpectedly. System.ArgumentNullException: Value cannot be null. #293

Open kentcb opened 5 years ago

kentcb commented 5 years ago

Ran into this after adding an actor service:

3>C:\Users\Kent\Repository\<<redacted>>\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets(94,5): error MSB4018: The "GetServiceProjectReferences" task failed unexpectedly.
3>C:\Users\Kent\Repository\<<redacted>>\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets(94,5): error MSB4018: System.ArgumentNullException: Value cannot be null.
3>C:\Users\Kent\Repository\<<redacted>>\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets(94,5): error MSB4018: Parameter name: source
3>C:\Users\Kent\Repository\<<redacted>>\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets(94,5): error MSB4018:    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
3>C:\Users\Kent\Repository\<<redacted>>\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets(94,5): error MSB4018:    at Microsoft.VisualStudio.Azure.Fabric.BuildTasks.ServiceModelServiceSlim.GetPrimaryCodePackage(ServiceManifestSlim serviceManifest)
3>C:\Users\Kent\Repository\<<redacted>>\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets(94,5): error MSB4018:    at Microsoft.VisualStudio.Azure.Fabric.BuildTasks.GetServiceProjectReferences.SetMetadataForProjectReferences(PackageBehaviorOptions packageBehavior)
3>C:\Users\Kent\Repository\<<redacted>>\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets(94,5): error MSB4018:    at Microsoft.VisualStudio.Azure.Fabric.BuildTasks.GetServiceProjectReferences.Execute()
3>C:\Users\Kent\Repository\<<redacted>>\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets(94,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
3>C:\Users\Kent\Repository\<<redacted>>\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets(94,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Turns out it's because there was no code package defined in the service manifest, and that's because I had enabled <UpdateServiceFabricManifestEnabled>false</UpdateServiceFabricManifestEnabled> reflexively when adding the project. I did that because of this other bug. sigh

Just leaving this here for future me and in case others run into it.

olivergrimes commented 5 years ago

@kentcb Where had you set <UpdateServiceFabricManifestEnabled>false</UpdateServiceFabricManifestEnabled>? I'm having this exact issue when creating a blank solution with a new actor project. The setting above in my csproj is True.

I've updated VS & the SF SDK to the latest versions (16.2.5, 3.4.664.9590, .NET Core 2.2) but I still can't create a blank actor service project that builds...

lanfeust69 commented 4 years ago

I had the same error, when creating a fresh new SF app.

In my case the root cause was that the template used version 3.4.641 of Microsoft.ServiceFabric.Actors package, where there is a bug in the .targets file (fixed in latest version 3.4.677), which would only copy *.dll and *.exe, but also the ActorAssembly.deps.json manifest, and check against said manifest. When using .Net Core 3.0, there is also a SOS_README.md that is mentioned in the manifest, but not copied, and that fails the task that should update the ServiceManifest.xml. With a still almost empty ServiceManifest.xml, that gets you the failure of GetServiceProjectReferences.

olivergrimes commented 4 years ago

I forgot to revisit this after I'd resolved the issue. I re-installed VS and it worked! Not sure it's the best resolution but I was at a dead end.