Blazor project builds locally but not in azure pipeline - c#

I have a blazor server project using .net 5. I am able to run it fine locally and connect to my API. In my local project I have a swaggerClient and swagger.json file. In startup I call
swaggerClient swagclient = new swaggerClient(Constants.baseAddress, httpClient2);
Everything works fine locally, even if I deploy to IIS again works fine. I am now setting up pipeline in azure for CI/CD and have a dotnet core template to build my project. Anyways when it comes time to build in azure I have about 100+ plus errors that are all referencing classes that exist in my swaggerClient and Cannot find the file. For example:
/home/vsts/work/9/s/obj/Release/netcoreapp3.1/RazorDeclaration/Pages/Index.razor.g.cs(2952,75): error CS0246: The type or namespace name 'swaggerClient' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/9/s/FDI.csproj]
Anyways i'm not sure if i'm setting up the pipeline correctly or if there is any additional configuration I need to do to get this to work, i've been looking all over thanks.
Also I was referencing how Tim Corey connects to an API in this video: https://www.youtube.com/watch?v=nY-w9wPFEuY&ab_channel=IAmTimCorey

Looks like dev ops didn't have the reference to the swagger file in my project file and wasn't properly detecting changes, so it was never checked in properly.

Related

SSIS package with Script task does not work when deployed programmatically

I am running into the weird issue that the script component of an SSIS package deployed as part of an ISPAC file fails if the project deployment is done in an automated fashion - from C# or using PowerShell, that is. Deploying the exact same project using the Integration Services Deployment Wizzard in Visual Studio does not raise any erros when executing the package on the server.
However, I am getting various errors about things missing in the system namespace when executing the package that has been deployed with C# (using Microsoft.SqlServer.Management.IntegrationServices) such as:
DFT Load STG_ETL_TEST_STAGING_CDC:Error: CS0234 - The type or
namespace name 'ComponentModel' does not exist in the namespace
'System' (are you missing an assembly reference?),
Properties\Resources.Designer.cs, 59, 25
DFT Load STG_ETL_TEST_STAGING_CDC:Error: CS0234 - The type or
namespace name 'CodeDom' does not exist in the namespace 'System' (are
you missing an assembly reference?), Properties\Resources.Designer.cs,
25, 21
I exported the deployed packages and compared their file sizes. I noticed that the ISPAC of the manually deployed project is slightly bigger than the one deployed programmatically. What is the Deployment Wizzard doing to the project that isn't happening during automated deployment?
To exclude that it has something to do with my C# code, I also tried the following PowerShell script from the Microsoft docs. However, it does use the same assembly as I use in my code (Microsoft.SqlServer.Management.IntegrationServices) and the deployed package has the same issues.
I should have mentioned that the project was generated with Biml. Turned out the issue was not related to the binaries but the ISPAC file created by the Biml compiler. Building the project again with VS (using devenv.com theproject.dtproj -build) solved the issue for me and allowed for programmatic deployment of the project.

Compiler error referencing Service Fabric Actor class from ASP.NET Core service

This has been bugging me all day and I have yet to figure out why this is happening.
Basic scenario
Created a new Service Fabric Application with an ASP.NET Core service and added support for returning MVC views so that it can act as the UI for my SF App.
Added an Actor service for users to the solution which created the UserActor and UserActor.Interfaces projects and ensured that the Interfaces library targets x64 as required by SF.
Defined a Task<UserProfile> GetProfileData() method on the UserActor where the UserProfile type is a concrete class defined in the Interfaces project with the [DataContract] and [DataMember] attributes so that it can be serialized (all members are primitives).
Added a project reference to the UserActor.Interfaces from the ASP.NET Core project so I could create the actor proxy and invoke the method.
Added the code in the ASP.NET Core Controller class to connect to the actor instance and invoke the GetProfileData method
At this point, I receive the following compiler error:
error CS0246: The type or namespace name 'UserProfile' could not be found (are you missing a using directive or an assembly reference?)
The relevant lines of code are as follows:
using UserActor.Interfaces;
var user = ActorProxy.Create<IUserActor>( new ActorId( model.email ), FabricAppUrl );
UserProfile profile = user.GetProfileData().Result; // compiler error here
If I hover over the UserProfile type on the last line, Visual Studio shows me it sees the type as UserActor.Interfaces.UserProfile and doesn't show any errors in the editor. It's only when I compile that this error shows up.
I didn't receive this error when trying to return a primitive type and it had no problem resolving the IUserActor interface for the Actor Proxy either.
Does this have something to do with the fact the the Actor projects are standard .NET projects and the ASP.NET Core project is compiled using dotnet build (set to .NETFramework,Version=v4.5.2; not dotnet core).
I also noticed in the build output that the ASP.NET Core project is building as 'Debug Any CPU' while all of the other projects are set to 'Debug x64'. If this were the issue I would expect to receive an error about mis-matched architecture types, but I'm not getting that either.
How can I resolve this? Should I be returning the data from the Actor in a different manner (such as json serializing it before returning it as a string primitive)?
Edit 1:
The code sample above was too simplistic. The 2 compiler errors I am seeing are around the type being passed to a helper method in the same controller as follows:
private bool TryGetUserProfile( LoginModel model, out UserProfile profile )
{
var user = ActorProxy.Create<IUserActor>(new ActorId(model.Email), FarbicAppUrl);
var profile = user.GetProfileData().Result;
return !string.IsNullOrEmpty(profile.Name);
}
OK, after starting the whole scenario out on a different machine I found what the problem is and believe it to be a Microsoft tooling issue. Here are the steps to reproduce the problem along with what needs to be done to correct it.
Create a new Service Fabric project and select ASP.NET Core as the service. If prompted, select the Web Application Template (but I think this would be an issue if you selected the Empty or Web API templates as well). If you debug this, it will work just fine (provided you have a local cluster setup).
Add a new Actor Service to the solution. This will create the UserActor and UserActor.Interfaces projects for you. If you try to compile at this point, you will receive the following error message:
C:\Program Files (x86)\MSBuild\bin\Microsoft.Common.CurrentVersion.targets(724,5): error : The OutputPath property is not set for project 'UserActor.Interfaces.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='AnyCPU'. This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform.
Checking the Configuration Manager shows that there is only an 'x64' target defined for the project. To get around this, use the Configuration Manager and add a new 'AnyCPU' target and copy it from the 'x64' target. Ensure that the target platform is still set to 'x64' for the interfaces project before closing the Configuration Manager since Service Fabric requires x64 assemblies.
Now when you compile, you will receive the following error message:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : C:\...\Web error CS0006: Metadata file 'C:\...\UserActor.Interfaces\bin\Debug\UserActor.Interfaces.dll' could not be found.
The clue here is that the web project is looking in the OutputPath location defined for the 'AnyCPU' target and not the location defined for the 'x64' target (bin\x64\Debug). If you manually edit the interfaces project file and set the OutputPath for the 'AnyCPU' target to the same path as the 'x64' target, everything will compile properly.
You can also deploy the project and everything will work as it should. I'm not sure which target file from Microsoft has the problem in it, but it could be both. I'll look into reporting this as a bug with Microsoft in the hopes of getting it resolved (still present with the latest SDK released on 2/3/2017).
The reason the UserProfile type couldn't be found for me was because I had previously built the solution with the wrong OutputPath set before I added the UserProfile class to the project so the compiled DLL that MSBuild was looking at didn't contain the type. If I had removed the bin & obj folders from the solution, it would have become obvious where the problem was right away.

Mono on Ubuntu Server and System.Web.Entiy

I've a project developed with monodevelop and I've added to it and external reference for System.Web.Entity. This project run correctly on my local machine, so I've decided to port it on my server.
I create a new docker instance with ubuntu 15.10 (same on my local) and I install all mono dependencies.
I build my project and all works fine. Well, I put it on run with xsp4 and I suppose that all is ok but when I call a service request I get this error
Can't find custom attr constructor image: /tmp/root-temp-aspnet-0/23703349/assembly/shadow/b7cd78f2/34e8ce56_8325b6a4_00000001/System.Web.Entity.dll mtoken: 0x0a000022
So I've try to "install" System.Web.Entity on local reference with
gacutil -i System.Web.Entity.dll
but in this case I receive this error:
Failure adding assembly System.Web.Entity.dll to the cache: Strong name cannot be verified for delay-signed assembly
Now I can't understand what/where is the trouble because in local I had only insert a manual reference to System.Web.Entity.dll in monodevelop and then all is started without problem.
Anybody help me?

Need help in modifying OWIN (Katana) for running VS2013's MVC WebApplication in Raspberry Pi

I want to run Visual Studio 2013's default MVC WebApplication in Raspberry Pi 2. I managed to install mono 4.0.1 and Lighttpd as the web server, and I was able to get this default MVC WebApplication (with no authentication) run on the Raspberry machine. However, when I tried the same MVC WebApplication but with "Individual Authentication", it gives the following error:
System.MissingMethodException: Method 'HttpApplication.RegisterModule' not found.
After googling, I found it here that this method 'RegisterModule()' is not implemented in mono's System.Web.HttpApplication. And the solution is to rebuild OWIN. I have never done that before. I used 'Git Bash' to clone the Katana as follow:
git clone https://git01.codeplex.com/katanaproject
then modified the PreApplicationStart.cs accordingly, and then run 'build' in command prompt, and it successfully created the Microsoft.Owin.Host.SystemWeb.dll under the project directory. I then tried to replace the original dll with this new one in Visual Studio 2013, and hit F5 to try to run it, and get the following errors:
The type 'Microsoft.Owin.IOwinContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null'.
and
'Microsoft.Owin.IOwinContext' does not contain a definition for 'GetUserManager' and the best extension method overload 'Microsoft.AspNet.Identity.Owin.OwinContextExtensions.GetUserManager<TManager>(Microsoft.Owin.IOwinContext)' has some invalid arguments
Is this the proper way to rebuild the OWIN and update this Microslft.Owin.Host.SystemWeb.dll? Any suggestion to get it work?
Thanks.
Got it work by using Visual Studio 2013 to build the project Microsoft.Owin.Host.SystemWeb directly, then use the result Microsoft.Owin.Host.SystemWeb.dll to replace the one used in the original MVC WebApplication project.

Why do I get this error in a WebServices project?

I have a ClickOnce app that accesses a bunch of web services. On the client, I have one project that wraps all the web services.
In the Properties for that project, if Build/Generate Serialization Assembly is Auto (which is the default), then everything works fine. I set the option to On, it compiles fine, then during runtime I get this error:
Line 786: [WebMethod]
Line 787: public CC.DTO.AdvertiserAssignmentRevenueDTO[] SearchAdvertiserAssignmentRevenue(byte[] AdvAssgnRevenueSearchFilter)
Line 788: {
Line 789: try
The Detailed Compiler Output is basically "CS0234: The type or namespace name 'DTO' does not exist in the namespace 'CC' (are you missing an assembly reference?)"
Why is this happening?
Just FYI, this is a .NET 2.0 project running in VS2008.
I had a very similar error message with the same symptoms. For me it would even run locally but not on a different server. It turned out I was missing a data contract declaration on one of my methods.
[DataContract (Namespace = ...)]
Double check your methods on the service and client to ensure they have all the needed attributes and declarations.

Categories