Mapster.Tool Code Generation for Specific Project - c#

I have a Visual Studio solution containing various sample console app projects. One of which is MapsterSample where I am trying out Mapster and following the steps described on GitHub https://github.com/MapsterMapper/Mapster/wiki/Mapster.Tool to generate mapping code.
Everything seems fine except for the part where I issue the command:
dotnet msbuild -t:Mapster
This results in the command executing for every project in the solution even if MapsterSample is selected as Default project in Package Manager Console:
SampleSolution\FirstSample\FirstSample.csproj : error MSB4057: The target "Mapster" does not exist in the project.
SampleSolution\SecondSample\SecondSample.csproj : error MSB4057: The target "Mapster" does not exist in the project.
... and so on
Is there a way to just execute the command for the MapsterSample project?

Make sure the project exists within your solution.
Make sure that the name Mapster is spelled correctly.
Make sure your terminal is in the correct directory. (ideally you should be in the directory ABOVE the directory the .csproj for Mapster is in.

Related

unable to implement gRPC having issues with Protos\greet.proto: No such file or directory

I'm trying to use gRPC for one of the microservice using this URL in ASP NET 6.0. I have also installed the required package "Grpc.AspNetCore" Version="2.48.0". But it still gives me compilation error about 'Protos\greet.proto: No such file or directory', path\Could not make proto path relative 1
'
I tried to make path relative but still no luck.
I'm running on visual studio 2022 and did make update to make sure that it is not because of update. I also tried creating another test project with gPRC project template and it worked but when i tried to add another service it gets failed again in test project too.
working with manual way for now.

DotNet MAUI Blazor App build with razor class library (Android/iOS)

Certificate configured as per the guide-line. We are able to generate build without razor class library. When we try to generate build with razor class getting below error.
dotnet\sdk\6.0.400-preview.22301.10\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResoluti
on.targets(267,5): error NETSDK1005: Assets file '\Razo
rClassLibrary\obj\project.assets.json' doesn't have a target for 'net6.0-android'. Ensure that restore has run and that
 you have included 'net6.0-android' in the TargetFrameworks for your project. [C:/RazorClassLibrary\RazorClassLibrary.csproj]
Tried with below options
Removed obj folder
Restore Nuget Package
Visual Studio update
MSBuild update
Added <RuntimeIdentifier>android-arm64</RuntimeIdentifier>
Spending more than two days, Really appreciate any guide to resolve this issue.
I suggest you try this
In Library project .csproj replace TargetFramework by plural -> <TargetFrameworks>net6.0;net6.0-android</TargetFrameworks>
In App project .csproj, I set android to API21, in my case with API31 didn't work.
In App project, right click, properties, Go to Android / Options / Package Sign, and complete complete info from keystore

MSBuild successful but Visual Studio failed

We're using Jenkins to build out projects using msbuild.
I added a project reference to an existing project but forgot to add these new project to all solution files.
I committed but Jenkins told me that everything works fine.
I tried that on command line:
msbuild test.sln /t:Rebuild /p:Configuration=Debug
Having a totally cleared working directory that works fine, in Jenkins and on my developing machine. The output told me that msbuild found that project and build it.
But if I open Visual Studio 2017 and try to build that solution, it tells me that the depending project could not be found.
That's correct.
How do I force msbuild to only build projects that are specified in the solution file so that we're able to find all solutions that missed that new project?
BTW: We don't need a hint how to find all solutions that need to contain that new project. Finding that solutions is pretty easy.
How do I force msbuild to only build projects that are specified in the solution file so that we're able to find all solutions that missed that new project?
The correct way to avoid MSBuild's default behavior of rebuilding all the dependencies listed in the solution file is to set the BuildProjectReferences property to false, So the build command line should be:
MSBuild Test.sln /t:Rebuild /p:Configuration=Debug /p:BuildProjectReferences=false
After using this command line, MSBuild will get the same error with VS, so we're able to find all solutions that missed that new project
Note: BuildProjectReferences will check all the dependencies listed in the solution file, so please keep his value is true, unless used to check the missing dependencies.
Hope this helps.

The target "RunResolvePublishAssemblies" does not exist in the project

I'm working on a WPF application, using VS 2017 version 15.3.3
I was curious to know what's behind the file type Azure Function:
When I added it there was nothing changed in the solution explorer, I ignored that and continued my work (which has nothing to do with Azure), but when I compiled the project I get this error:
The target "RunResolvePublishAssemblies" does not exist in the project
and this warning:
Error encountered while loading the project. Some project features,
such as full solution analysis for the failed project and projects
that depend on it, have been disabled
I switched the solution explorer to view all files, and I found the azure function class is hidden in the place I added in, I deleted it, but the same problem still exist
Please, help!
For me this problem was happening because we switched Azure functions project back from dot net core to 4.5.1. So i deleted 'bin' and 'obj' folders from each of the projects, and re-build. It started working fine for me once deleting these 2 folders. I was able to clean and build the projects. My unit tests are also passing fine.
This GitHub error log helped me with this error: https://github.com/Azure/azure-functions-vs-build-sdk/issues/92
Following this suggestion resolved my build error:
To work-around this specific issue , you may be able to give an empty target in your csproj
<Target Name="RunResolvePublishAssemblies" /> but I am not sure what else would be broken without using the SDK style projects.

ASP.net MVC SecretManager

I have an ASP.net MVC 5.2 project on a macOS Sierra (not my choice unfortunately) and I am trying to set the client secrets with the SecretManager. I have tried running
dotnet user-secrets set Authentication:Twitter:ConsumerKey <consumer-key>
but I get that
No executable found matching command "dotnet-user-secrets"
I executed the command in the project root and after googling the problem, apparently I need to run the command in the same folder as the project.json which I cannot find in my project structure. (do I need to create it manually?)
I apologise in advance for these beginner questions but I am just getting on board with the .net framework.
Any tips/ideas would be greatly appreciated!
As far as I know now projects use .csproj files instead of project.json, so you have to use it in the folder containing .csproj file
Judging from your project structure I guess it's "TwitterMania" folder - the one nested inside another "TwitterMania" folder

Categories

Resources