Getting error while building the code in visual studio

hi,

I’m trying to run the code (which I downloaded from github that is attached as a part of this course) and I’m getting build errors. Can you please help?

2 Likes

Hmm looks like something has the path hardcoded in there, but I’m not seeing this on a new machine with the code.
Can you please provide a few things, so I can try to replicate it here:

  1. What steps are you doing exactly that get you that error (the exact menu options or keyboard shortcuts or right-click options you’re using)
  2. What version of Visual Studio are you running?
1 Like

hi Hilary,

Thanks for checking. I’m using visual studio 2019 in windows. Also using .net core sdk 6 (latest version) since .net core sdk 2 is no logner supported.

Steps:

I just downloaded the code from git repository and unzipped it in my local machine and opened the solution in visual studio 2019 > Build the code. I’m getting the following error:

Build started…
1>------ Build started: Project: APIChecksWithRestSharp, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK1138: The target framework ā€˜netcoreapp2.2’ is out of support and will not receive security updates in the future. Please refer to .NET and .NET Core official support policy for more information about the support policy.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1166,5): warning MSB3191: Unable to create directory ā€œC:\Users\g33kl\source\repos\APIChecksWithRestSharp\APIChecksWithRestSharpā€. Access to the path ā€˜C:\Users\g33kl\source\repos\APIChecksWithRestSharp\APIChecksWithRestSharp’ is denied.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1166,5): warning MSB4181: The ā€œMakeDirā€ task returned false but did not log an error.
1>CSC : error CS0016: Could not write to output file ā€˜C:\Users\g33kl\source\repos\APIChecksWithRestSharp\APIChecksWithRestSharp\APIChecksWithRestSharp.xml’ – ā€˜Could not find a part of the path ā€˜C:\Users\g33kl\source\repos\APIChecksWithRestSharp\APIChecksWithRestSharp\APIChecksWithRestSharp.xml’.’
1>Done building project ā€œAPIChecksWithRestSharp.csprojā€ – FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Please Note that I have Mac with me too…I tried in Mac as well. In Mac the build was successful with visual study 2019 Mac. But I’m having another problem after I installing restsharp, tried to create the class library and did few coding related to restsharp by following the course…It throws few errors in the var response = restrequest(Method.Get)

1 Like

Hilary, I’m seeing the xml file(highlighted) in Mac while running the code which I’m not seeing in windows.

2 Likes

Thank you so much for this, it helps a lot!
I think I just need to update the base code to the latest frameworks and that’ll take care of a lot of the issues you’re seeing. I’ll make sure to do that this week.
With the RestSharp error, did you install the latest RestSharp version? There are breaking changes with the latest version unfortunately. If you can downgrade to 106.6.10 that would might work - if you’re already using that version, then I’ve got other stuff to update!

1 Like

Thanks so much for investigating Hilary. I just installed the Restsharp package from visual studio as you mentioned in the course. Meanwhile, I will if downgrading the version of Restsharp helps. Please let me know if you find a fix so that I can continue with the course. Thanks for offering such a great course Hilary. I appreciate your effort.

2 Likes

2 things:
I found out how to fix the documentation error issue with the XML you initially described:

  1. Edit the .csproj file for the main API project (APIChecksWithRestSharp)
  2. in the PropertyGroup section, add this: <GenerateDocumentationFile>true</GenerateDocumentationFile>
  3. Do a fresh build - hopefully this fixes it!

The other thing:
I did the upgrade, and it looks like you’ll have to go to Visual Studio 2022 (still community/free edition) to make it work with .NET 6 - that’s the latest version and has long term support.
Here’s the base code upgraded to the latest https://github.com/g33klady/APIChecksWithRestSharp/tree/feature/dotnet_upgrade
Please note! I did the upgrade and go through any build/running issues with CRUD tests but I haven’t done a complete test of everything (I might need to write some unit tests lol). It’s not merged in yet because it’s still experimental, but you may have some success with it. I also haven’t touched RestSharp’s latest version yet to see what changes need to be made, so please take this with that grain of salt. I wanted to get this out there ASAP

1 Like

Hi Hilary,

Thanks so much. I will upgrade the visual studio and check with the latest base code to see if that works.

Regards,
Mohana

1 Like