Why does my Visual Studio Online build keep failing? - c#

For some reason it keeps failing because it can't find some assemblies and I don't understand why it can't find them. It's an ASP.NET MVC application.
In the build definition my Source Settings is set to the src/ folder which contains the projects in my solution and the packages folder.
The build process template is TfvcTemplate.12.xaml which I'm pretty sure is one of the defaults.
Clean workspace: true
Label sources: true
Projects: My application's solution file
Clean build: true
Output location: SingleFolder
My errors are as follows
Controllers\CompanyController.cs (11): The type or namespace name 'OfficeOpenXml' could not be found (are you missing a using directive or an assembly reference?)
Global.asax.cs (7): The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Services\ExcelExportService.cs (8): The type or namespace name 'OfficeOpenXml' could not be found (are you missing a using directive or an assembly reference?)
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Could not resolve this reference. Could not locate the assembly "Antlr3.Runtime". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Could not resolve this reference. Could not locate the assembly "EPPlus". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Could not resolve this reference. Could not locate the assembly "System.Web.Optimization". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Could not resolve this reference. Could not locate the assembly "WebGrease". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1697): Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
I checked deeper into the logs and I can see that it's trying to find them but all it gets is "Considered blablablabla, but it didn't exist."
Why can't it find my nuget packages?

Related

C# - Recompiling old code, running into errors (are you missing an assembly reference?)

First and foremost, I've never worked with C#, or any compiled language for that matter. So I'm hoping I'm just doing something wrong here.
We have an old in house app, written in c# that has some smtp settings hard coded that need to be changed. I have the source files, and even the .sln visual studio project file. So I open the project in vs, make the required changes, and go to build- however I'm running into errors (Build -> Build 'Autodocs' (the name of our app)):
Build started...
1>------ Rebuild All started: Project: AutoDocs, Configuration: Debug Any CPU ------
1>C:\shared\New folder\AutoDocs\Microsoft\Office\Interop\Word\Documents.cs(10,38,10,54): error CS0234: The type or namespace name 'CustomMarshalers' does not exist in the namespace 'System.Runtime.InteropServices' (are you missing an assembly reference?)
1>C:\shared\New folder\AutoDocs\AutoDocs\modules\DWStorer.cs(7,7,7,15): error CS0246: The type or namespace name 'DocuWare' could not be found (are you missing a using directive or an assembly reference?)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
So does anybody have any suggestions for a c# newbie like me? Anything I should have to do when copying a project dir from the server to my pc to build it?
Thank you in advance.
Do you know what kind of program it is? Windows? ASP.NET? MVC?
The errors are shown, but let's go through them:
1>C:\shared\New folder\AutoDocs\Microsoft\Office\Interop\Word\Documents.cs(10,38,10,54):
error CS0234: The type or namespace name 'CustomMarshalers' does not exist in the
namespace 'System.Runtime.InteropServices' (are you missing an assembly reference?)
First, look in this document:
C:\shared\New folder\AutoDocs\Microsoft\Office\Interop\Word\Documents.cs
Somewhere in that file, when viewing in Visual Studio, you will see the word CustomMarshalers, and it needs to be referenced.
So, in your project, you will need to right-click the References section and add that missing reference (if it isn't there already):
Also, at the top of your Documents.cs file, you need to have a line like this:
using System.Runtime.InteropServices;
See Microsoft's documentation here: System.Runtime.InteropServices.CustomMarshalers
Here is your second error:
>C:\shared\New folder\AutoDocs\AutoDocs\modules\DWStorer.cs(7,7,7,15):
error CS0246: The type or namespace name 'DocuWare' could not be found
(are you missing a using directive or an assembly reference?)
Similar to the first error, this one is having an error in the DWStorer.cs file because it cannot resolve the keyword DocuWare.
DocuWare is a third party tool that must be added to your references and added to the top of your DWStorer.cs file.
DocuWare
You may have to go to the link above to download their tool if you do not have it in your project somewhere.

Could not locate the assembly when using absolute path

I'm trying to add an assembly reference to my project in Rider, and when doing so, I can normally navigate to the desired folder and select the .dll. The selected .dll immediately appears under assemblies, despite having a warning sign next to it (hovering over it yields no extra information). When trying to build, I get the following error:
Microsoft.Common.CurrentVersion.targets(2127, 5): [MSB3245] Could not resolve this reference. Could not locate the assembly "Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
The same happens if I try to build the project from terminal using either xbuild or msbuild. If it makes any difference, I'm using Linux.

The type or namespace name 'OpenIdConnect' does not exist in the namespace 'Microsoft.Owin.Security' (are you missing an assembly reference?)

I have added a Microsoft.Owin.Security.OpenIdConnect.dll externally(tried both methods using Package Manager Console and using add reference ) to my ASP.NET MVC Application, but still get the same error.
The type or namespace name 'OpenIdConnect' does not exist in the namespace 'Microsoft.Owin.Security' (are you missing an assembly reference?)
I have attached AccountController.cs, packages.config and references
Any help.
You can try with deleting Package folder from source directory (Location: .sln file), then try to resotre packages.
Steps to restore nuget packages:
Right click on solution file.
Select Nuget restore NuGet Package option
I found the solution from Microsoft site
https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/0e92xd7b(v=vs.110)
Possible causes for this error include the following:
An assembly that contains the definition of a type was not referenced in the compilation; use /reference (Import Metadata) to specify the assembly
You passed a variable name to the typeof operator.
You tried to reference an assembly that is not part of your target .NET Framework profile. For more information, see Troubleshooting .NET Framework Targeting Errors.
In my case, the issue is that an assembly that is not part of my target .NET Framework profile.

Linking a resource file to an existing .NET assembly using Assembly Linker

I am trying to link the file name.ext to assembly.dll using the AL (Assembly Linker) to mimic what can be done in C++ using the /ASSEMBLYLINKRESOURCE option.
The syntax I am using is the following:
al.exe assembly.dll /link:name.ext
and I get the following error:
ALINK: error AL1017: No target filename was specified
I also tried:
al.exe assembly.dll /out:outAssembly.dll /link:name.ext
getting the following error:
ALINK: warning AL1020: Ignoring included assembly 'assembly.dll'
ALINK: error AL1019: Metadata failure while creating assembly -- The system cannot find the file specified.
What I am doing wrong? What is the correct syntax to obtain the resource link?
Thanks.
The Assembly Linker generates a file that has an assembly manifest from one or more files that are either modules or resource files. A module is an intermediate language (IL) file that does not have an assembly manifest.
assembly.dll can not be the source of Assembly Linker because it already is an assembly with manifest. So you get this
ALINK: warning AL1020: Ignoring included assembly 'assembly.dll'

asp.net mvc3 application opened in Visual Studio 2012, Could not locate the assembly "EntityFramework"

I opened and edited an ASP.NET MVC 3 application developed in Visual Studio 2010, in Visual Studio 2012. It was working fine in Debug mode but when I tried to publish it (release mode), it failed and threw following warnings and errors.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "EntityFramework". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
error CS0234: The type or namespace name 'Infrastructure' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?)
error CS0246: The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'DbModelBuilder' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'DbSet' could not be found (are you missing a using directive or an assembly reference?)
EntityFramework.dll is present in bin folder and EntityFramework 5.0 is installed. Can this be resolved ?
What am I doing wrong while migrating this project? Microsoft says no modifications are needed when going from VS 2010 to VS 2012 http://msdn.microsoft.com/en-us/library/vstudio/jj161050.aspx#ASP.
If there is a file called packages.config in the project, open it and remove the reference to EntityFramework (something like <package id="EntityFramework" ... />). Also remove the reference to the assembly from the project (select the assembly under 'References' and delete it) and remove the assembly from the bin folder.
Now you can reinstall the package using the package manager (right click the project and select "Manage NuGet Packages").

Categories