actions / setup-dotnet

Set up your GitHub Actions workflow with a specific version of the .NET core sdk
MIT License
919 stars 454 forks source link

error MSB4057: The target "pipelinePreDeployCopyAllFilesToOneFolder" does not exist in the project. #449

Closed hercul1017 closed 10 months ago

hercul1017 commented 10 months ago

Description: For Publish to folder step build fails with the error MSB4057: The target "pipelinePreDeployCopyAllFilesToOneFolder" does not exist in the project.

We have .net 4.8 solution that consist of a web project and a few library projects. Azure app services created yaml file for github actions. Although visual studio publish is successful, github actions fails with mentioned error.

on: push: branches:

jobs: build: runs-on: windows-latest

steps:
  - uses: actions/checkout@v2

  - name: Setup MSBuild path
    uses: microsoft/setup-msbuild@v1.0.2

  - name: Setup NuGet
    uses: NuGet/setup-nuget@v1.0.5

  - name: Restore NuGet packages
    run: nuget restore

  - name: Publish to folder
    run: msbuild /nologo /verbosity:diag /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="\published\"

  - name: Upload artifact for deployment job
    uses: actions/upload-artifact@v2
    with:
      name: ASP-app
      path: '/published/**'

Like the error says the Target pipelinePreDeployCopyAllFilesToOneFolder is not defined any of the project of the solution. Do I need to define the target for all projects if so how or is there any other solution. Thanks.

Task version: all versions failed so far.

Platform:

Runner type:

Repro steps:
Initial setup failed for .net mvc 4.8 project. Running yaml file,

Expected behavior: Successful publish to azure app service.

Actual behavior: Publish fails.

marko-zivic-93 commented 10 months ago

Hello @hercul1017, Thank you for letting us know about this issue. We will investigate and come back as soon as we have some relevant feedback.

IvanZosimov commented 10 months ago

Hi, @hercul1017 👋 Could you please clarify that you're using the setup-dotnet. I don't see it in the provided yml snippet.

hercul1017 commented 10 months ago

Hi @IvanZosimov I use the default yml file created by azure. It does not have setup-dotnet step. It seems [windows-latest](runs-on: windows-latest) does not guarantee latest .net 4.8.1 SDK installation.

However I could not find setup-dotnet command step for .net 4.8.1 example. It seems all of the examples reference .net core versions.

Do you know how to install .net 4.8.1 to windowns-latest machine. Actually it doesn't have to be the windows-latest, working solution would be greatly appreciated.

hercul1017 commented 10 months ago

I tried many different script to install .net 4.8.1 to the runner but I could not.

Found this check that shows that .net 4.8.1 is not installed.

Now I am really frustrated. It seems setup-dotnet is only for .net core versions as far as I understand. Clearly help is needed.

IvanZosimov commented 10 months ago

Hi, @hercul1017 👋 Unfortunately, the setup-dotnet action doesn't support installing .NET Framework versions. But, the windows-latest image has preinstalled version of .NET Framework 4.8.1, see documentation. You can double check that running this command:

(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" -Name Version).Version

With that said and as your issue isn't related to the setup-dotnet itself, I'm closing it now. If you have any question related to the version preinstalled on the image, I'd recommend you to create issue here: https://github.com/actions/runner-images

hercul1017 commented 10 months ago

Hi @IvanZosimov thank you for clearing if .net framework 4.8.1 whether exists or not. However this answer does not address the error I am getting. You are the one who asked if setup-dotnet exists in the yml file and directed investigation to installing the framework. Then, as you said issue is not related to the setup-dotnet itself.

The runner showed Installed .NET Framework version: 4.8.09037. The same as my local machine.

If the framework is not the issue, what could it be? I am compiling and running locally and also I can publish to azure by using visual studio. When I use github actions I am getting the mentioned error. I was expecting seamless integration. I am still getting the same error.

IvanZosimov commented 10 months ago

Hi, @hercul1017, without seeing the code and project structure it's hard to say where the problem is. Nonetheless I suspect that the problem is in the msbuild command arguments. Have you tried the same command locally? Maybe the problem is in the migration process from compiling and running in UI of VisualStudio to doing the same using msbuild? I'd recommend you to take a look at this answer. Hope it will help 🙏