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
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.
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. How do I fix this missing dlls or referenced binaries? If I need to copy files from bin folder to the build directory, how?
Error CS0246: The type or namespace name 'RestSharp' could not be found
Tested using.dll file path in bin folder as 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.
This is my solution to solve this issue:
Step1: Add the package reference in Packages.config
file.
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. Since you add the package reference, you could directly get the RestSharp.dll in the package path.
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.
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. This can avoid the error above.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.