question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NuGet restores Service Fabric project with .NET Framework 4.7.2 instead of .NET Core 3.1

See original GitHub issue

I’ve been trying to setup a SeviceFabric CI in DevOps and I am unable to find a way to tell MSBuild that my app is a .NET Core app and not a .NET Framework 4.7.2 app. Is there another way to do that from within my project file aside from the usual .NET Core TargetFramework element in csproj file so MSBuild stops thinking that it is a .NET Framework app?

Type: Question Task Name: MSBuild Agent: Hosted

image

pool:
  name: Azure Pipelines
  demands:
  - msbuild
  - Cmd

variables:
  BuildPlatform: 'x64'

steps:
- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 3.1.x'
  inputs:
    version: 3.1.x

- task: NuGetToolInstaller@1
  displayName: 'Use NuGet '
  inputs:
    checkLatest: true

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Parameters.solution)'

============================
===This is where it fails===
============================
- task: MSBuild@1
  displayName: 'Build solution **/*.sln'
  inputs:
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'
    msbuildArguments: '/p:Deterministic=true /p:PathMap=$(Agent.BuildDirectory)=C:\'

- task: MSBuild@1
  displayName: 'Build solution **\*.sfproj'
  inputs:
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'
    msbuildArguments: '/t:Package /p:PackageLocation=$(build.artifactstagingdirectory)\applicationpackage'

- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)\pdbs'
  inputs:
    SourceFolder: '$(build.artifactstagingdirectory)\applicationpackage'
    Contents: '**\*.pdb'
    TargetFolder: '$(build.artifactstagingdirectory)\pdbs'

- task: DeleteFiles@1
  displayName: 'Delete files from $(build.artifactstagingdirectory)\applicationpackage'
  inputs:
    SourceFolder: '$(build.artifactstagingdirectory)\applicationpackage'
    Contents: '**\*.pdb'

- task: ServiceFabricUpdateManifests@2
  displayName: 'Update Service Fabric Manifests (Manifest versions)'
  inputs:
    applicationPackagePath: '$(build.artifactstagingdirectory)\applicationpackage'
    versionSuffix: '.$(build.buildnumber)'
    updateOnlyChanged: true
    pkgArtifactName: drop

- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)\projectartifacts'
  inputs:
    SourceFolder: '$(system.defaultworkingdirectory)'
    Contents: |
     **\PublishProfiles\*.xml
     **\ApplicationParameters\*.xml
    TargetFolder: '$(build.artifactstagingdirectory)\projectartifacts'
  condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
  condition: succeededOrFailed()

Fails with error

##[error]The nuget command failed with exit code(1) and error(NU1201: Project Delivery is not compatible with net472 (.NETFramework,Version=v4.7.2). Project Delivery supports: netcoreapp3.1 (.NETCoreApp,Version=v3.1)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19

github_iconTop GitHub Comments

1reaction
temeljcommented, Jul 23, 2020

I have a feeling your issues are again caused by how you’ve setup your repository and pipeline and nothing to do with a “bug” in nuget restore and the pipeline tasks.

As for Directory.Build.props - don’t place them in the solution folder - that’s an anti pattern. I have mine in the src folder where all projects are. (Note that the sfproj is under the repo root)

I have an additional Directory.Build.props in my tests folder which is slightly different - contains coverlet specific package references.

1reaction
secret-agent-Bcommented, Jul 2, 2020

The only options there when I created the service fabric project was .NET Framework. But the service within we’re all created using .NET Core.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploying .Net framework 4.7.2 to Azure service fabric
I have a existing applcation, which consists some webapi projects, some class libraries and some WorkerRole projects (that uses Microsoft.
Read more >
For a .Net Core 2.1 project, Why does Nuget restores .Net 4.6 ...
net framework package> was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'.
Read more >
Nuget restore - system cannot find file - Microsoft.Build ...
Framework, Version=15.1.0.0 ... Everytime I try to run Nuget restore I get this error. ... NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\ System.Net.
Read more >
Use Azure Service Fabric with the .NET Framework or .NET ...
NET Core agent to an Azure Service Fabric service: ... Install the appropriate NuGet package to the main project for the service. .NET...
Read more >
Build Services - MyGet Documentation
Since NuGet 2.7 was released, MyGet Build Services runs NuGet Package Restore as part of every build of solution or project files even...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found