unable to build a asp.net app in azure devops

后端 未结 1 1878
误落风尘
误落风尘 2021-01-22 02:06

Able to build the app locally, but when am trying to build in azure devops pipeline.It showing below errors

I have installed EntityFramework and added system.data.entity

1条回答
  •  梦毁少年i
    2021-01-22 02:40

    According to the build log which shared from @Stella, this error message should caused by the package restored path.

    Firstly, it's all succeed to restore the relevant package with the Nuget restore task. And also, the packages needed all has been restored. It's restored folder location is D:\a\1\s\webapp\Websites\packages which same with location defined in Nuget.config ..\packages

    In the Visual Studio Build log, there has the following message:

    Considered "..\ThirdParty\NuGetPackages\EntityFramework.6.1.2\lib\net45\EntityFramework.dll", but it didn't exist.
    ***
    ***
    Considered "..\ThirdParty\NuGetPackages\EntityFramework.6.1.2\lib\net45\EntityFramework.SqlServer.dll", but it didn't exist.
    ***
    ***
    ***
    

    According to these message which displayed in Visual Studio Build task, you can see it is finding the package location under the folder path ..\ThirdParty\NuGetPackages. As normal, this path is controlled by the ... .

    Now, it would be very easy to know the error caused: the package location which found during the build does not match with its actually package restored location in Nuget restore task.

    As normal, its default location should be ..\packages\..., which same with default location defined in Nuget.config. I assume its local repos path should ever be changed, then its HintPath which defined in csproj file are also be changed automatically. But, in Nuget.config, its package default location are still keep default. That will cause when package restore, it follow the location defined in Nuget.config. But during build time, since it look for the package with the csproj ... defined, build can not know the actually package restored location. Then caused these error message.


    To solve this issue, there has 2 solutions.

    • Reinstall packages in Visual Studio

    Run the below command to reinstall all of packages, thus the HintPath can all changed into default location ..\packages\..., which can sync with defined in Nuget.config.

    Update-Package -reinstall
    

    This logic of this solution is revoke HintPath as default location, thus it can keep sync with definition in Nuget.config.

    After execute the command, the HintPath should same look as this:

    • Modify the Nuget.config file

    The logic of second solution is modify the package location definition in Nuget.config file. Make it sync with HintPath, at this time, the location of the package restored will be the same as the location of the package at build time.

    Add the following script into Nuget.config file:

    
      
        
      
      ... 
    
    

    Just try with one solution, then build in Visual Studio locally. After it is succeed, then push it into Azure Devops, build with the same task configuration previously, use nuget, nuget restore, VS build, publish artifacts.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题