[英]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.