Facing build error with System.Net.IMAP4 in Azure DevOps - c#

I have a C# project in my local and it is working perfectly in my local machine. When I try to build the same project through Azure DevOps it gives the following build error
[error]d:\a\1\s\packages\System.Net.Imap4.0.1.0\System.Net.Imap4.sln.metaproj(0,0):
Error MSB3202: The project file
"d:\a\1\s\packages\System.Net.Imap4.0.1.0..\example\example.csproj"
was not found.
d:\a\1\s\packages\System.Net.Imap4.0.1.0\System.Net.Imap4.sln.metaproj
: error MSB3202: The project file
> "d:\a\1\s\packages\System.Net.Imap4.0.1.0..\example\example.csproj"
was not found.
[d:\a\1\s\packages\System.Net.Imap4.0.1.0\System.Net.Imap4.sln]
Project
"d:\a\1\s\packages\System.Net.Imap4.0.1.0\System.Net.Imap4.sln" (1) is
building
"d:\a\1\s\packages\System.Net.Imap4.0.1.0\System.Net.Imap4.csproj"
In the IMAP4 library, it specifically says that the following file was not found. When I added the package through Nuget Package Manager it installed perfectly but does not download the mentioned file example/example.csproj in the packages/System.Net.Imap4.0.1.0 folder.
d:\a\1\s\packages\System.Net.Imap4.0.1.0\System.Net.Imap4.sln.metaproj : error MSB3202: The project file "d:\a\1\s\packages\System.Net.Imap4.0.1.0..\example\example.csproj" was not found.
System.Net.Imap4.0.1.0 package structure
System.Net.Imap4.0.1.0/lib/net35 (inside the lib there are no files and it contains only net35 folder)
System.Net.Imap4.0.1.0/properties
What I am missing here to build the project successfully?
Note: I tried to view the hidden files also but the example.csproj file was not found.

Facing build error with System.Net.IMAP4 in Azure DevOps
This issue should comes from that nuget package. I have download that nuget package from nuget.org, then I unzip it, I found that the package did not contain the file example.csproj:
So, this issue related to the package, I am not sure if you are the Owners/Authors of that package, if yes, you need to re-create that package.
In addition, I have a long time to use/support nuget. According to my experience, this package is not correct. As we know, nuget:
An essential tool for any modern development platform is a mechanism
through which developers can create, share, and consume useful code.
Often such code is bundled into "packages" that contain compiled
code (as DLLs) along with other content needed in the projects that
consume these packages.
But that package packaged the entire project, which is not the correct way, it should only include the dll files.
You can check this document for some details.
Hope this helps.

The build error resolved with the following changes.
Navigate to this folder path /../System.Net.Imap4.0.1.0
Open the System.Net.Imap4.sln file and remove or comment the example/example.csproj line from the file.
Build the project
Build is successful

Related

The type or namespace name 'TwilioRestClient' could not be found

This is what I did:
went to
https://www.twilio.com/docs/authy/tutorials/account-verification-csharp-mvc
downloaded the code and built the code using VS2017 community edition.
I get the following error in IdentityConfig.cs
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'TwilioRestClient' could not be found (are you missing a using directive or an assembly reference?) AccountVerification.Web C:\Users\admin\Downloads\account-verification-csharp-master\account-verification-csharp-master\AccountVerification.Web\App_Start\IdentityConfig.cs 21 Active
What is the problem?
I changed nothing. Just downloaded and built the code. Shouldn't you guys give a working copy of the code?
I've managed to get this working by following these steps:
Close the solution in Visual Studio if you have it opened.
Ensure you have a nuget CLI in your path. So you can run a restore from a command prompt. This is pretty straightforward. Instructions here.
Open a command prompt at the solution directory. (C:\Users\admin\Downloads\account-verification-csharp-master\account-verification-csharp-master for you.)
Run a nuget restore. nuget restore and wait for it to finish.
You should get all the packages downloaded at the packages directory under your solution folder.
UPDATE - Looking at the code it appears that there's a mix of features from the latest version 5.x and the now deprecated version 4.x, and that's causing compilation errors. Details here.
Follow the below steps to downgrade the version to 4.7.2:
Open the solution file now.
Right-click the web project and select Manage Nuget Packages.
Search for Twilio and downgrade the version from 5.x to 4.7.2.
a) Or from the Package Manager Console Install-Package Twilio -Version 4.7.2
Solution should build successfully now.
Please bear in mind that you must setup the parameters in Local.config file before the app can work. It'll run though, but you'll not be able to go through it until the parameters are properly set.
Note: The solution contains a file named Local.config.example. When you open the solution you'll notice that Local.config file is missing.
Renaming the existing Local.config.example file to Local.config solves that issue. I had to copy the Local.config file to the test project too. This doesn't prevent the solution from building, though.
Hope this helps!

Nuget & dotnet on linux - using/package a provided package

perhaps Im getting old but Im really confused on how to use a nupkg on Linux. Resolving and installing dependencies/adding libs for C is easier for me (never would thought I would say so).
I got a package from a vendor (YYYYY_linux.3.0.77.nupkg) and want to run their example code (version for windows with visual studio worked out of the box) but they told me their linux pack would also work.
What I did:
dotnet init
... coding ...
dotnet restore
dotnet build
/home/tobiass/code/XXXX/Program.cs(27,11): error CS0246: The type or
namespace name 'YYYYY' could not be found (are you missing a using
directive or an assembly reference?)
Afterwards I tried two things:
1.
I edited NuGet.Config
dotnet restore
The nupkg shows up as a feed.
But I still get the same error.
2.
I also tried to create a local feed
mono nuget.exe add ../YYYYYYY_linux.3.0.77.nupkg -source ./
but it always results in
The requested feature is not implemented.
What is the correct way on Linux to add a library? Must it be also a part of project.json? Some config in .nuget?
Best,
Tobias
I suspect your project is not a .NET Core project so you should be using nuget.exe instead of dotnet.
So first I would take a look at the example code. Does it have a .csproj file? Does it have a packages.config file? Does it have a packages folder with the .nupkg file in it already? If so then nothing needs to be done and it should just compile.
From the error message one or more of the above are not correct. If the project file (.csproj) has references to the files in the NuGet package and there is an existing packages.config file then all you need to do is restore the package. To do that you need to put the NuGet package somewhere so it can be restored. You could simply just copy the .nupkg file into ~/.local/share/NuGet/Cache/ which is the machine cache for all NuGet packages and then restore it into the project by running nuget restore Path/To/YourSolution.sln.
If the project does not have a packages.config file then you would need to install it into the project. The simplest way would be to use MonoDevelop. That has built-in support for adding NuGet packages to projects.
Otherwise you could just unzip the .nupkg file and copy the files where they need to go into the solution's packages directory based on the information in the .csproj file.

Dapper won't install on Xamarin

Adding Dapper to Xamarin iOS project is giving me NuGet installation errors because it apparently misses some target assemblies.
Adding Dapper... Downloading Dapper 1.50.0... Installing 'Dapper
1.50.0'. Added file 'Dapper.dll' to folder 'Dapper.1.50.0/lib/net40'. Added file 'Dapper.xml' to folder 'Dapper.1.50.0/lib/net40'. Added
file 'Dapper.dll' to folder 'Dapper.1.50.0/lib/net45'. Added file
'Dapper.xml' to folder 'Dapper.1.50.0/lib/net45'. Added file
'Dapper.dll' to folder 'Dapper.1.50.0/lib/net451'. Added file
'Dapper.xml' to folder 'Dapper.1.50.0/lib/net451'. Added file
'Dapper.dll' to folder 'Dapper.1.50.0/lib/netstandard1.3'. Added file
'Dapper.xml' to folder 'Dapper.1.50.0/lib/netstandard1.3'. Added file
'Dapper.1.50.0.nupkg' to folder 'Dapper.1.50.0'.
Successfully installed 'Dapper 1.50.0'.
Adding 'Dapper 1.50.0' to iOS. Could not install package 'Dapper
1.50.0'. You are trying to install this package into a project that targets 'Xamarin.iOS,Version=v1.0', but the package does not contain
any assembly references or content files that are compatible with that
framework. For more information, contact the package author.
Did anyone found any workaround to add Dapper to Xamarin iOS Project?
I think you may be having a fundamental architecture misunderstanding. If you are to access anything other than a local database such as SQL Lite, that should be done over REST or something similar, reaching a web service endpoint. That service will then do the database access and possibly use Dapper.
In any event, the message is clear - there is no Dapper release compatible with iOS. You may try getting the source and create your own assemblies, but it may simply not be feasible.

NuGet targets wrong folder when publishing web application via MSBuild.exe in CI

I am trying to set up a project in our CI server (bamboo).
I have an API solution containing multiple projects (data access, service interfaces, WebApi, tests, a few others... you get the idea). I run nuget.exe in a script to pull in the requisite packages at the solution level. The packages go into the solution directory .nuget.
When I use MSBuild to create the binaries, everything is fine. I then use the MSTest runner on the test projects; still everything is fine. I then shut down the destination web service, and then run msbuild.exe against the WebApi project with the parameters /p:DeployOnBuild=true /p:PublishProfile=INTENV.
This is where bamboo barks at me. I get the failure error message like so:
error : This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\(My Solution Folder)\\.nuget\NuGet.targets.
The project is obviously looking for the dependencies in the project folder, in this case and in this case only.
How do I tell MSBuild.exe that this folder is one level up? This is the only place where it gets confused.
So what was happening when I targeted the project instead of the solution with MSBuild.exe is that it considered $(SolutionDir) to be the project directory. It was looking for the the nuget targets at $(SolutionDir).nuget\NuGet.targets, which was an incorrect path if starting at the project level, but perfectly fine at the solution level.
On my MSBuild.exe command line, I added a parameter as follows:
/property:SolutionDir="(path of my solution)"
This did the trick.
I also tried to change the project settings, but NuGet always replaced them; the above manner is the only way I could get it to work.

Nuget: Deploy to IIS or Share Code

This is the first time I have used NuGet and I think my question may be so basic that I can't find the answer.
Question 1)
I downloaded NuGet packages on VS2012
-Install-Package EntityFramework -Version 6.1.0
-Install-Package Microsoft.AspNet.Web.Optimization
When I create a copy of my application code, a VS2012 C# asp.net website directory and try to run it without a solution I get an error that looks like the website is not finding the Nuget packages.
If I need to share a code directory with a colleague so they can help work on it what is the process to do that?
When it comes time to deploy the code directory to IIS in production what is the process to do that? Can I simply copy the code over to the webserver as previous? Are there steps to take to ensure the Nuget packages are referenced?
Further details below:
Using VS 2012 I added the following NuGet packages to the solution:
Install-Package EntityFramework -Version 6.1.0
Install-Package Microsoft.AspNet.Web.Optimization
My target version is .NET framework 4.0 to match production.
When I move the code to another location on my computer or share it with a colleague it generates the error below.
Server Error in '/Portalv4' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'Column' could not be found (are you missing a using directive or an assembly reference?)
`Source Error:
Line 64: public DateTime FailedPasswordAnswerAttemptWindowStart { get; set; }
Line 65:
Line 66: [Column(TypeName = "ntext")]
Line 67: public string Comment { get; set; }
Line 68:
`
OK here is a weird thing- if I switch VS2012 to run the project under IIS Express the it will compile and run just fine. Any ideas as to why it does not work under Visual Studio Development server once it is separated from the solution file? There are many dll warnings about not being able to refresh under both VS Dev Server and IIS express.
Your application's ability to compile does not depend on your NuGet packages directly. The packages.config file simply remembers what was installed with NuGet so that it can manage updating and uninstalling of packages.
However, when you install a NuGet package, it will add files throughout your project. Once you install or remove a package, be sure to save your Project so that references to the package are saved. If you copy your project before saving, the package files will be in the project directory but you won't see them in the VS Solution Explorer.
Regardless of whether this is the cause of your error. You can track down the error by going to your original project, determine what assembly defines 'Column' (as described in the error) and make sure that the assembly is in the References folder of the copies project.
Good luck.
If I need to share a code directory with a colleague so they can help work on it what is the process to do that?
Start using source/version control technology, for example Git or Team Foundation Server (TFS). Both integrate nicely in Visual Studio. TFS is available for free for up to five users.
Once you're using source control, make sure to choose 'Enable Nuget Package restore' in your solution (right-click the solution in Solution Explorer). Without this option enabled, all Nuget packages will be added to your source control and you don't want that.

Categories