Jenkins/ .net core 2.0/ ubuntu missing assemblies - c#

I set up an ubuntu 16.04 machine with Jenkins, nodejs, and .net core 2.0, and then tried to have it build my .net core 2.0 web application. It failed with the following message(s):
16:32:26
/usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(1987,5):
warning MSB3245: Could not resolve this reference. Could not locate
the assembly "Microsoft.AspNetCore.Authorization". Check to make sure
the assembly exists on disk. If this reference is required by your
code, you may get compilation errors.
[/var/lib/jenkins/workspace/MySolution Main
App/MySolution.Common/MySolution.Common.csproj] 16:32:26
/usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(1987,5):
warning MSB3245: Could not resolve this reference. Could not locate
the assembly "Microsoft.AspNetCore.Mvc.Abstractions". Check to make
sure the assembly exists on disk. If this reference is required by
your code, you may get compilation errors.
[/var/lib/jenkins/workspace/MySolution Main
App/MySolution.Common/MySolution.Common.csproj] 16:32:26
/usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(1987,5):
warning MSB3245: Could not resolve this reference. Could not locate
the assembly "Microsoft.IdentityModel.Tokens". Check to make sure the
assembly exists on disk. If this reference is required by your code,
you may get compilation errors. [/var/lib/jenkins/workspace/MySolution
Main App/MySolution.Common/MySolution.Common.csproj] 16:32:26
/usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(1987,5):
warning MSB3245: Could not resolve this reference. Could not locate
the assembly "System.IdentityModel.Tokens.Jwt". Check to make sure the
assembly exists on disk. If this reference is required by your code,
you may get compilation errors. [/var/lib/jenkins/workspace/MySolution
Main App/MySolution.Common/MySolution.Common.csproj] 16:32:27
Security/Decorators/ForbiddenResult.cs(5,28): error CS0234: The type
or namespace name 'Mvc' does not exist in the namespace
'Microsoft.AspNetCore' (are you missing an assembly reference?)
[/var/lib/jenkins/workspace/MySolution Main
App/MySolution.Common/MySolution.Common.csproj] 16:32:27
Security/Decorators/GroupMemberAttribute.cs(3,28): error CS0234: The
type or namespace name 'Mvc' does not exist in the namespace
'Microsoft.AspNetCore' (are you missing an assembly reference?)
[/var/lib/jenkins/workspace/MySolution Main
App/MySolution.Common/MySolution.Common.csproj] 16:32:27
Services/Impl/TokenManagementService.cs(10,14): error CS0234: The type
or namespace name 'IdentityModel' does not exist in the namespace
'System' (are you missing an assembly reference?)
[/var/lib/jenkins/workspace/MySolution Main
App/MySolution.Common/MySolution.Common.csproj] 16:32:27
Services/Impl/TokenManagementService.cs(12,17): error CS0234: The type
or namespace name 'IdentityModel' does not exist in the namespace
'Microsoft' (are you missing an assembly reference?)
[/var/lib/jenkins/workspace/MySolution Main
App/MySolution.Common/MySolution.Common.csproj] 16:32:27
Security/Decorators/ForbiddenResult.cs(9,33): error CS0246: The type
or namespace name 'IActionResult' could not be found (are you missing
a using directive or an assembly reference?)
[/var/lib/jenkins/workspace/MySolution Main
App/MySolution.Common/MySolution.Common.csproj] 16:32:27
Security/Decorators/ForbiddenResult.cs(18,40): error CS0246: The type
or namespace name 'ActionContext' could not be found (are you missing
a using directive or an assembly reference?)
[/var/lib/jenkins/workspace/MySolution Main
App/MySolution.Common/MySolution.Common.csproj] 16:32:27
Security/Decorators/GroupMemberAttribute.cs(8,51): error CS0246: The
type or namespace name 'IActionFilter' could not be found (are you
missing a using directive or an assembly reference?)
[/var/lib/jenkins/workspace/MySolution Main
App/MySolution.Common/MySolution.Common.csproj] 16:32:27
Security/Decorators/GroupMemberAttribute.cs(33,33): error CS0246: The
type or namespace name 'ActionExecutingContext' could not be found
(are you missing a using directive or an assembly reference?)
[/var/lib/jenkins/workspace/MySolution Main
App/MySolution.Common/MySolution.Common.csproj] 16:32:27
Security/Decorators/GroupMemberAttribute.cs(53,32): error CS0246: The
type or namespace name 'ActionExecutedContext' could not be found (are
you missing a using directive or an assembly reference?)
[/var/lib/jenkins/workspace/MySolution Main
App/MySolution.Common/MySolution.Common.csproj] 16:32:27
Security/Decorators/GroupMemberAttribute.cs(58,24): error CS0246: The
type or namespace name 'ActionExecutingContext' could not be found
(are you missing a using directive or an assembly reference?)
[/var/lib/jenkins/workspace/MySolution Main
App/MySolution.Common/MySolution.Common.csproj]
On my dev machine, I looked around and couldn't find those assemblies, but I'm definitely referencing them, so I'm guessing they're stashed in a common location somewhere.
What do I need to do to get all the referenced assemblies to be found by Jenkins and successfully build my project? All the documentation I've seen online seems to reference .net core 1.0 or 1.1 and it seems a lot of this stuff is different now.
My build steps are very simple (there's one). A script to do:
dotnet clean
dotnet restore
dotnet build

SO IT TURNS OUT that this is a bug (perhaps of ReSharper) where if you reference a library in your solution in a project for the first time, and automagically update the reference, the reference isn't added completely correctly; IOW, the MySolution.Common project did not explicitly add the dependent assemblies to the project file, even though they were part of the solution and available.
On my development machine, that didn't matter so much; Visual Studio was able to find the dependencies just fine. On my build server, however, this was a critical piece of information that was missing.
HOW TO CORRECT
If we take a look at the first error:
16:32:26 /usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.AspNetCore.Authorization". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/var/lib/jenkins/workspace/MySolution Main App/MySolution.Common/MySolution.Common.csproj]
...we can see that the problem occurred when building the MySolution.Common project, and the missing assembly was Microsoft.AspNetCore.Authorization.
There are two ways to make this work. One is to manually edit the .csproj file. If you add the line in the PackageReference ItemGroup like so:
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="2.0.1" />
... the problem (for that missing reference) will go away. This is what I originally did, and it worked, but then I found out that I could do this without messing with that file by simply going to my Package Management Console and doing something like this:
cd MySolution.Common
dotnet add reference Microsoft.AspNetCore.Authorization
...this would add it to the project file properly, along with the proper version and everything, so I think this is a better method.
I hope this saves someone the hours it cost me.

Related

Getting Errors on the Hooks and Step definition file for the dot net 4.6 framework and specflow 3.9.8

I am getting the below errors in my code in the Hooks file and Step definition file while working on the .net 4.6 framework(Visual Studio 2019). Please let me know if I missed any of the specflow packages. If I # using TechTalk.SpecFlow; it gets highlighted in red. Please let me know if I am missing assembly reference. Do I need to install any other specflow package?
Errors:
Error CS0246 The type or namespace name 'GivenAttribute' could not be found (are you missing a using directive or an assembly reference?).Error CS0246 The type or namespace name 'BeforeScenario' could not be found (are you missing a using directive or an assembly reference?) Error CS0246 The type or namespace name 'BindingAttribute' could not be found (are you missing a using directive or an assembly reference?).Error CS0246 The type or namespace name 'Binding' could not be found (are you missing a using directive or an assembly reference?).Error CS0103 The name 'ScenarioStepContext' does not exist in the current context
Also attaching the packages list:
SpecFlow version is 3.9.8, SpecFlow.MsTest version is 3.9.8, SpecFlow.Tools.MsBuild.Generation version is 3.9.8 and targetFramework is net46
Do I need to install any other specflow package?

Azure deployment fails with build errors

I have been trying to deploy my web application to azure for two days now. I had finished programming the application and its working properly locally, when i pushed to application to github, and I'm using my student starter plan to deploy it. The application starts deploying then it fails with errors. The errors are below
/usr/share/dotnet/sdk/3.0.100/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Extensions.Identity.Stores". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Administration/SchoolRole.cs(1,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Administration/SchoolUser.cs(1,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Tenancy/TenancyRole.cs(1,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Tenancy/TenancyUser.cs(2,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Administration/SchoolRole.cs(5,31): error CS0246: The type or namespace name 'IdentityRole<>' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Administration/SchoolUser.cs(7,31): error CS0246: The type or namespace name 'IdentityUser' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Tenancy/TenancyRole.cs(5,32): error CS0246: The type or namespace name 'IdentityRole<>' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Tenancy/TenancyUser.cs(7,32): error CS0246: The type or namespace name 'IdentityUser' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
1 Warning(s)
8 Error(s)
I had even changed the host now to Azure DevOps but it still show me the same thing. This has pushed me to rewrite the application from start. It runs locally okay but when i publish it, it fails.
I too faced the same issue. While publishing VS build was failing with - Unable to find dependent project references, but with release version I was able to build the solution.
The fix which worked for me was -
Update VS version to Version 16.7.3.
With this version project build passed successfully and I was able to deploy the packages...in earlier version I think there was a problem with dependency resolver.

Travis-CI build failure "The type or namespace name 'Extensions' does not exist in the namespace"

Still new to Travis-CI and wanted to see if it's something I'm doing or not. I'm getting a build error in Travis-CI, but not locally.
Sample .NET Core 2.0 app. Going through the build I receive the following errors:
error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
and
error CS0246: The type or namespace name 'IConfiguration' could not be found (are you missing a using directive or an assembly reference?)
Here's a link to the config and job log:
https://travis-ci.org/ovation22/DapperRepository/jobs/273068340
There is a warning just above the error:
/usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Extensions.Configuration.Abstractions". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/travis/build/ovation22/DapperRepository/Example.Repository/Example.Repository.csproj]
DapperRepository.cs(7,17): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/home/travis/build/ovation22/DapperRepository/Example.Repository/Example.Repository.csproj]
DapperRepository.cs(16,33): error CS0246: The type or namespace name 'IConfiguration' could not be found (are you missing a using directive or an assembly reference?) [/home/travis/build/ovation22/DapperRepository/Example.Repository/Example.Repository.csproj]
Lets take a look at Example.Repository.csproj:
<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.2" />
</ItemGroup>
That looks fine. But where is Microsoft.Extensions.Configuration.Abstractions? Lets look a little lower:
<Reference Include="Microsoft.Extensions.Configuration.Abstractions">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.configuration.abstractions\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
</Reference>
So you are telling msbuild that it is available at C:\Program Files. Travis is running this in Linux where this path obviously doesnt exist.
Try adding a PackageReference just like Dapper in that csproj. That should fix this.

Properly include a project with .NET core

I am trying to compile some C# code with .NET Core. My last attempt was hindered by YamlDotNet not supporting .NET Core, but that has changed.
So, I set up a project like this:
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\YamlDotNet\YamlDotNet\YamlDotNet.csproj" />
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
</PropertyGroup>
</Project>
I ran:
dotnet restore
That was successful. Then I tried:
dotnet build
This yielded the following error:
/usr/share/dotnet/sdk/1.0.1/Microsoft.Common.CurrentVersion.targets(1111,5):
error MSB3644: The reference assemblies for framework ".NETCoreApp,Version=v1.0"
were not found. To resolve this, install the SDK or Targeting Pack for this
framework version or retarget your application to a version of the framework for
which you have the SDK or Targeting Pack installed. Note that assemblies will be
resolved from the Global Assembly Cache (GAC) and will be used in place of
reference assemblies. Therefore your assembly may not be correctly targeted for
the framework you intend.
[/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
/usr/share/dotnet/sdk/1.0.1/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.targets(92,5):
error : Cannot find project info for '/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj'.
This can indicate a missing project reference.
[/work/yaml-editor/docker/src/dotnet/dotnet.csproj]
I am using the official microsoft/dotnet:1.0-sdk docker container, so I don't understand why .NETCoreApp,Version=v1.0 is missing. How can I fix the error?
Update:
I figured out that I have to configure <TargetFramework>netstandard1.3</TargetFramework> which is also present in YamlDotNet.csproj. However, now I get this error:
/usr/share/dotnet/sdk/1.0.1/Microsoft.CSharp.CurrentVersion.targets(133,9): warning MSB3884: Could not find rule set file "MinimumRecommendedRules.ruleset". [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Core/YamlException.cs(113,30): error CS0115: 'YamlException.GetObjectData(SerializationInfo, StreamingContext)': no suitable method found to override [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Core/YamlException.cs(112,26): error CS0234: The type or namespace name 'Permissions' does not exist in the namespace 'System.Security' (are you missing an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Core/YamlException.cs(112,57): error CS0234: The type or namespace name 'Permissions' does not exist in the namespace 'System.Security' (are you missing an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Core/YamlException.cs(112,112): error CS0246: The type or namespace name 'Flags' could not be found (are you missing a using directive or an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Core/YamlException.cs(112,120): error CS0234: The type or namespace name 'Permissions' does not exist in the namespace 'System.Security' (are you missing an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Serialization/Utilities/TypeConverter.cs(45,26): error CS0234: The type or namespace name 'Permissions' does not exist in the namespace 'System.Security' (are you missing an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Serialization/Utilities/TypeConverter.cs(45,52): error CS0234: The type or namespace name 'Permissions' does not exist in the namespace 'System.Security' (are you missing an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Serialization/Utilities/TypeConverter.cs(45,107): error CS0246: The type or namespace name 'Name' could not be found (are you missing a using directive or an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
Serialization/Utilities/TypeConverter.cs(47,54): error CS0234: The type or namespace name 'TypeConverter' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?) [/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj]
/usr/share/dotnet/sdk/1.0.1/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.targets(92,5): error : Cannot find project info for '/work/yaml-editor/docker/YamlDotNet/YamlDotNet/YamlDotNet.csproj'. This can indicate a missing project reference. [/work/yaml-editor/docker/src/dotnet/dotnet.csproj]
make: *** [build/bin/dotnet-event] Error 1
I remember to have seen similar errors when I last tried this, but I wonder why it still happens, since YamlDotNet claims to support .NET Core.
I had the same error, which I resolved by adding:
using YamlDotNet.RepresentationModel;
Try adding one of the four namespaces and see which works:
using YamlDotNet.Serialization
using YamlDotNet.RepresentationModel
using YamlDotNet.Helpers
using YamlDotNet.Core

How can I host asp.net core application in in-proc in IIS?

I am trying to host the asp.net core application and for that I tried Nowin as it is given in Documentation, But even Nowin creates the another process names MyProject.exe.
I want to install IIS in In proccess of app pool instead of creating the different process(Kestrel). Second thing is I use default project template of aspnet core and commented use Kestrel and added Nowin as given in samples. It still creates the new process. The reason I need it to be in same process because Performance monitoring tool I use (NewRelic) does not yet support Kestrel. If I create new project in mvc 5, Empty template and then add aspnewcore nuget packages, It comes till controller, But when It goes to razor it gives error(It works perfect with return Json). Can you help me to know whether it is issue or not? If it is not issue, How can I achieve it? Which type of project I should create?
Error in old website project with aspnet core nuget.
One or more compilation failures occurred:
4nut20vs.g5q(10,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
4nut20vs.g5q(11,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
4nut20vs.g5q(12,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
4nut20vs.g5q(15,36): error CS0234: The type or namespace name 'ViewFeatures' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)
4nut20vs.g5q(16,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
4nut20vs.g5q(18,86): error CS1980: Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference?
4nut20vs.g5q(18,86): error CS0518: Predefined type 'System.Boolean' is not defined or imported
4nut20vs.g5q(18,45): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
4nut20vs.g5q(43,16): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'..........
It's not possible to host ASP.NET Core in process with IIS. See https://learn.microsoft.com/en-us/aspnet/core/publishing/iis for more details.
The reason I need it to be in same process because Performance monitoring tool I use (NewRelic) does not yet support Kestrel.
Sounds like the NewRelic support you're using is for System.Web based applications. Does it support profiling a managed exe?

Categories

Resources