Encountering a error while building .NET web api - c#

While trying to run a .net project i encounter the following error
C:\Users\h.kuhar\source\repos\Vacation2.0\VacationApi\VacationApi\VacationApi.csproj(425,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\6.0.400\Microsoft\VisualStudio\v17.0\WebApplications
\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\6.0.400\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication
.targets" is correct, and that the file exists on disk.
The project was downloaded of a git repo and the author is currently unavailable for support on the matter

Related

Cannot add package reference

I'm building a xamarin.ios app in VS mac. I'm trying to add a certain package, but when I try to add it I get this error
jon#jons-MacBook-Pro-2 helloworld % dotnet add package Ditto
/Users/jon/Desktop/hello-world/helloworld/helloworld/helloworld.csproj(140,5): error MSB4019: The imported project "/usr/local/share/dotnet/sdk/6.0.300/Xamarin/iOS/Xamarin.iOS.CSharp.targets" was not found. Confirm that the expression in the Import declaration "/usr/local/share/dotnet/sdk/6.0.300//Xamarin/iOS/Xamarin.iOS.CSharp.targets" is correct, and that the file exists on disk.
Unable to create dependency graph file for project '/Users/jon/Desktop/hello-world/helloworld/helloworld/helloworld.csproj'. Cannot add package reference.
I have also tried using the Nuget manager and I get this when I try to build the project
/Users/jon/Desktop/hello-world/helloworld/helloworld/MTOUCH: Error MT0009: Error while loading assemblies: /Users/jon/.nuget/packages/ditto/1.1.8/runtimes/win/native/dittoffi.dll. (MT0009) (helloworld)
Any thought??

msbuild throwing error for added link for resource in c# project

I want to create a common Version.cs which has copyright and assembly version infromation. I want same file to be refered by 2 projects using Add Link feature. So whenver there is new release I just want to make changes in Version.cs file. My both the prjected located in below location.
Below two projects are generated from
Project 1
C:\remote\local\Sources\myproj-template-archetype\target\test-classes\projects\snap_proj\project\snap_proj\MyLibrary_1
Project 2
C:\remote\local\Sources\myproj-template-archetype\target\test-classes\projects\snap_proj\project\snap_proj\MyLibrary_2
My Version.cs is located in C:\remote\local\Version.cs
Now when I try to build these project using mvn clean install. I am getting error for Version.cs. Error is
[INFO] [exec] CSC : error CS1566: Error reading resource
'Com.org.snap_proj.MyLibrary_1.Com.org.snap_proj.MyLibrary_1.Version.cs'
-- 'Could not find a part of the path 'C:\remote\local\Sources\myproj-template-archetype\target\test-classes\projects\snap_proj\project\snap_proj\MyLibrary_1\Com.org.snap_proj.MyLibrary_1\Version.cs'.'
[C:\remote\local\Sources\myproj-template-archetype\target\test-classes\projects\snap_proj\project\snap_proj\MyLibrary_1.csproj]

How to embed or-tools in a C# application?

I'm trying to follow the instructions at https://developers.google.com/optimization/introduction/installing.html#windows_binary so that I can use or-tools inside my C# application.
I'm stuck on the make all step. I am in the Developer Command Prompt, but this command says:
'make' is not recognized as an internal or external command,
operable program or batch file.
I tried downloading GNU make, but that fails also. make install says "no target", and a bare make says:
process_begin: CreateProcess(NULL, cl /EHsc /MD /nologo /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -nologo /O2 -DNDEBUG -DUSE_CBC -DUSE_CLP /D__WIN32__ /Iinclude\src\windows /DGFLAGS_DLL_DECL= /DGFLAGS_DLL_DECLARE_FLAG= /DGFLAGS_DLL_DEFINE_FLAG= /Iinclude /Iexamples -DUSE_GLOP -DUSE_BOP -c examples\cpp\costas_array.cc /Foobjs\costas_array.obj, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [objs\\costas_array.obj] Error 2
I also tried copying the DLLs from the bin folder directly into my project. I was able to compile against them by doing this, but when I tried to run it I got an error:
System.BadImageFormatException: 'Could not load file or assembly 'Google.OrTools, Version=5.1.6235.37215, Culture=neutral, PublicKeyToken=7a052e3db761d3be' or one of its dependencies. An attempt was made to load a program with an incorrect format.'
What am I missing?
Regarding the System.BadImageFormatException:
The OrTools binary format is provided in a 64bit dll.
Make sure, that your project is set to 64bit:
In Visual Studio you can check it out by right clicking on the Project --> Properties --> Build, Platform Target: This should be set to x64.
In case you have the same issue with web application, just enable 64 bits on IIS Express using Tools -> Options -> Projects and Solutions -> Web Projects -> Use the 64-bit version on IIS Express for web sites and projects
I was having this issue when using OR-Tools in a Web Application (it worked fine in a console application). I was getting:
System.BadImageFormatException HResult=0x8007000B Message=Could not load file or assembly 'Google.OrTools' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Using x64 didn't help, and Octopus was not building the project correctly either. The solution that worked for me was specifying which ASPNETCOMPILER to use (x64) in the project's .csproj :
<Project .... >
<PropertyGroup>
<AspNetToolPath>$(windir)\Microsoft.NET\Framework64\v4.0.30319</AspNetToolPath>
</PropertyGroup>

Can't publish ASP.NET 5 with external library reference

I have included an external reference of Moneris library eSELECTplus_dotNet_API.dll to my ASP.NET 5 RC1 project. It wrapped it alright and I can build project and run it using Kestrel. But when I publish it from VS or command line I got following error:
The package ID 'eSELECTplus_dotNet_API' contains invalid characters. Examples of valid package IDs include 'MyPackage' and 'MyPackage.Sample'.
I tried to rename library to a better name to fit nuget specs and it worked so I can publish it. But now when I run my project I got runtime error saying following:
System.IO.FileNotFoundException : Could not load file or assembly 'eSELECTplus_dotNet_API, Version=2.5.3.0, Culture=neutral, PublicKeyToken=8cb9cd598f87e276' or one of its dependencies. The system cannot find the file specified.
Please advice.

Azure Git Deployment Could not find file [Project].dll.licenses failure

We have an ASP.NET web application project in BitBucket which has a reference to a Class Library using Telerik Reporting. Telerik Reporting has a license associated (licenses.licx file).
Azure deployment fails with the message:
CSC : error CS1566: Error reading resource '[Project].dll.licenses' -- 'Could not find file 'D:\home\site\repository\src\[Project]\obj\Release\[Project].dll.licenses'.'
Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\Home\[PathTo].csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="D:\local\Temp\8d2bd89fc1c1e79";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release /p:SolutionDir="D:\home\[PathTo]\"
This existing question *.dll.licenses file in obj directory not created with msbuild in TeamCity and linked MSDN forum post seem to resolve this by installing extra tools - but I don't believe that would be an option in Azure?
The licenses.licx file in the class library is also set as an Embedded Resource which apparantly trips it up if not set correctly.
We were able to resolve the problem by removing the licenses.licx file from the repository (and ignoring it).

Categories