简体   繁体   English

如何将 dll 和其他二进制文件从 asp.net 网站的 bin 文件夹复制到 azure devops 管道

[英]How do I copy my dll and other binaries from bin folder in asp.net website to azure devops pipeline

I just created an azure pipeline from bitbucket cloud and using the default generated yaml file, when i run the Run New pipeline, I am getting errors in VsBuild saying我刚刚从 bitbucket 云创建了一个 azure 管道并使用默认生成的 yaml 文件,当我运行运行新管道时,我在 VsBuild 中遇到错误

    Error CS0246: The type or namespace name 'RestSharp' could not be found (are you missing a using directive or an assembly reference?)

The RestSharp.dll is located in my bin folder in asp.net website. RestSharp.dll 位于 asp.net 网站的我的 bin 文件夹中。

Looking at the raw logs, it says查看原始日志,它说

    2020-07-10T03:35:57.7771564Z           Considered "d:\a\1\s\mywebsite\Bin\RestSharp.dll", but it didn't exist.
    2020-07-10T03:35:57.7772002Z           For SearchPath "{TargetFrameworkDirectory}".
    2020-07-10T03:35:57.7772374Z           Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\RestSharp.winmd", but it didn't exist.
    2020-07-10T03:35:57.7772874Z           Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\RestSharp.dll", but it didn't exist.
    ...

However, when I build in VS 2019, there are no build errors, since I am referencing my dlls and binaries.但是,当我在 VS 2019 中构建时,没有构建错误,因为我引用了我的 dll 和二进制文件。 How do I fix this missing dlls or referenced binaries?如何修复此丢失的 dll 或引用的二进制文件? If I need to copy files from bin folder to the build directory, how?如果我需要将文件从 bin 文件夹复制到构建目录,如何?

Error CS0246: The type or namespace name 'RestSharp' could not be found错误 CS0246:找不到类型或命名空间名称“RestSharp”

Tested using.dll file path in bin folder as HintPath .使用 bin 文件夹中的 .dll 文件路径作为HintPath进行了测试。 I encountered the same issue.我遇到了同样的问题。

It seems that the root cause of this issue is that the RestSharp.dll doesn't exist in the Bin folder at the time of reference.此问题的根本原因似乎是在参考时 Bin 文件夹中不存在RestSharp.dll

This is my solution to solve this issue:这是我解决此问题的解决方案:

Step1: Add the package reference in Packages.config file.步骤 1:在Packages.config文件中添加 package 引用。

For example:例如:

<?xml version="1.0" encoding="utf-8"?>
<packages>
.....
  <package id="RestSharp" version="106.11.4" targetFramework="net472" />
</packages>

Step2: Change the RestSharp HintPath in .csproj file. Step2:更改.csproj文件中的 RestSharp HintPath Since you add the package reference, you could directly get the RestSharp.dll in the package path.由于您添加了 package 引用,因此您可以直接在 package 路径中获取 RestSharp.dll。

For example:例如:

<Reference Include="RestSharp">
  <Private>True</Private>
  <HintPath>..\packages\RestSharp.106.11.4\lib\net452\RestSharp.dll</HintPath>
</Reference>

Then the RestSharp.dll could be used in the build.然后可以在构建中使用 RestSharp.dll。

By the way, I recommend that you could turn them into packages, and restore them during build.顺便说一句,我建议您可以将它们转换为包,并在构建过程中恢复它们。 Then you could get the dll files in the package path.然后您可以在 package 路径中获取 dll 文件。 This can avoid the error above.这样可以避免上面的错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 azure DevOps 中将构建从一个管道复制到另一管道 - Copy Builds from one pipeline to other pipeline in azure DevOps How to deploy Asp.net web forms website to Azure Web App service using Azure DevOps? - How to deploy Asp.net web forms website to Azure Web App service using Azure DevOps? Azure Devops 部署 asp.net 网站(不是 webapp) - Azure Devops Deploy asp.net website(not webapp) Azure DevOps 发布管道:如何复制到我的 VM - Azure DevOps Release Pipeline: How to copy to my VM 我如何从 Azure Devops 构建/发布管道执行在我的 Azure Databricks 笔记本中编写的 ScalaTest 测试用例 - How do i execute the ScalaTest testcases written in my Azure Databricks notebook from Azure Devops build/release pipeline 如何从 ASP.NET 核心应用程序将图像上传到 Azure blob 存储中的特定目录? - How do I upload an image to a specific directory in my Azure blob storage from my ASP.NET Core application? 当我的 linting 脚本返回错误时,如何使我的 Azure DevOps Pipeline 构建失败? - How do I get my Azure DevOps Pipeline build to fail when my linting script returns an error? 如何从我的 ASP.NET 核心应用程序访问来自 Azure Active Directory 的其他数据? - How do I access additional data from Azure Active Directory from my ASP.NET Core application? 当我使用 .NET 在 Azure 上重新部署我的网站时,如何防止图像文件夹被覆盖? - How to prevent an image folder from being overwritten when I redeploy my website on Azure with .NET? 如何确保我的 Azure Devops Pipeline YAML 与我通过 Pipeline UI 所做的更改同步? - How do I make sure my Azure Devops Pipeline YAML is in sync to changes I make through the Pipeline UI?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM