dotnet cli <> VS2017 nuget packages restore errors - visual-studio

I've used dotnet cli (2.0.0) to create 2 projects:
dotnet new webapi (name: webapiProject)
dotnet new xunit (name: testProject)
after that, on testProject project:
dotnet add reference webapiProject
test project is an integration test and it uses webapiProjects Startup.
when i do dotnet run on xunit one, all works fine. tests run, references work, all good.
But, when i load testProject.csproj in VS2017 (15.3.3), i get nuget NU1105 error:
Severity Code Description Project File Line Suppression State
Error NU1105 Unable to find project information for 'webapiProject'. The project file may be invalid or missing targets required for restore.
I am actually rather new to dotnet cli and i am not even sure i should be loading *.csproj in VS2017 but i did so because when i opened only my test class then i didn't have intellisense for it.
So, any advice would be highly appreciated about both:
the error
correct workflow

Related

Publishing an asp.net core app from cli not deleting existing files using a publish profile

Trying to publish an app from the command line and its not deleting existing files in the destination directory before publishing.
Here is the command:
dotnet publish "myproject.csproj" /p:Configuration=Release /p:PublishProfile=FolderProfile
FolderProfile is the profile I am using in Visual Studio which works when run from VS. When run from the CLI it publishes just as expected, but doesn't wipe the destination directory first like VS does. Am I missing something?
Here is the publish profile view in VS:
And here is the publish profile edit window:
UPDATE: It seems that property is ignored when running from dotnet publish:
dotnet publish with /p:PublishProfile=?
https://github.com/dotnet/sdk/issues/12490#issuecomment-1085139911

Azure Devops build fails Warning MSB3245: Could not resolve this reference

I'm trying to create a pipeline in Azure DevOps and I get compilation errors caused by a missing reference:
[warning]C:\Program Files (x86)\Microsoft Visual
Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5):
Warning MSB3245: Could not resolve this reference. Could not locate
the assembly "ABC". Check to make sure the assembly exists on disk. If
this reference is required by your code, you may get compilation
errors.
I have a VS2017 solution with 2 projects.
ABC which is the actual application
ABC.UnitTests where I added some unit tests (I'm using MSTest)
When I build the solution locally, I'm able to do a successful build with the following steps:
Build ABC project => ABC.dll is generated
Add reference in ABC.UnitTests proj to ABC.dll
Build the entire solution => build successful
The .cs file in ABC.UnitTests references the application in this way, and generates the warning above:
using ABC;
If I do a clean build where ABC.dll is deleted and then I do a build of the entire solution I get the same MSB3245 warning. So the issue is reproducible locally if the dll does not exist.
Then, when I upload the solution to Azure DevOps, I do the following steps.
Upload the solution from local VS2017 and a project is created in Azure
Build the project in Azure DevOps => reference issue reported
I have a YAML config file with name azure-pipelines.yml which references the hosted 2017 agent.
pool: vmImage: 'vs2017-win2016'
Alternate flow:
Upload the solution from local VS2017 and a project is created in Azure
Comment out the reference to ABC.UnitTests project from the sln file
Create the pipeline => build successful.
You shouldn't refer any DLL as you mentioned in the comment.
The proper way is to refer to as a project. This way the DLL takes care of itself during the build
Proper way is
References -> (Right Click) Add References -> From that using Projects tab you can choose the Project which is generating that DLL(assemblies)
You can refer this SO

Error while running MSBuild.SonarQube.Runner against C# project

I’m trying to use MSBuild SonarQube scanner for my C# project. RootFolder has a .sln file, and each project (.csproj) is created in a separate folder inside the root folder. I've the project property file in RootFolder.
SonarQube server (LTS version 6.7.5) is up fine.
My Current env details:
Visual Studio 2010
.Net Framework 4.5.2
MSBuild version 4
sonarScanner for MSBuild 4.3.1.1372
Sonar Csharp Plugin version : 7.3.2.6129
When I’m trying to run below ‘begin’ command from project root directory, I see this error:
M:\myProjectCsharp>MSBuild.SonarQube.Runner.exe begin /k:”myProjectCsharp”/n: “myProjectCsharp”/v:”1.0”
Unhandled Exception: System.MissingMethodException: Method not found: '!!0[] System.Array.Empty()'.
at SonarScanner.MSBuild.Program.Execute(String[] args, Boolean showDeprecatedWarning)
at MSBuild.SonarQube.Runner.Program.Main(String[] args)
I guess it has something to do with compatibility of .Net Framework or MSBuild version ?
Also, what's the role of visual studio here, I already got.sln, .csproject and their corresponding .cs files in respective project directory under RootFolder 'myProjectCsharp'
(I don’t see any error if I simply run the sonar-scanner-msbuild-4.3.1.1372-net46\sonar-scanner-3.2.0.1227\bin\sonar-scanner but this doesn’t seems to update anything on dashboard (Just show 0 Bugs,Vulnerabilities & code smells) )
Any clue please ?
Thanks.

Unable to publish ASP.NET Core application with "CreateManifestFile" task could not be loaded

I have an ASP.NET Core app which I can publish using web deploy and pre-configured publishing profile via Visual Studio 2017. Now I need to configure CI and trying to achieve the same from the command line so I installed [.NET Core SDK][1] and followed this guide
dotnet build -c release /p:DeployOnBuild=true /p:PublishProfile=publish-profile-name
Unfortunately, it gives the following error:
C:\Program
Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk.Publish\build\netstanda
rd1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(227,5):
error MSB4062: The "CreateManifestFile" task could not be loaded from
the assembly C:\Program
Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0
....\tools\netcoreapp1.0\Microsoft.NETCore.Sdk.Publish.Tasks.dll.
Confirm that the declaration is correct, that the assembly
and all its dependencies are available, and that the task contains a
public class that implements Microsoft.Build.Framework.ITask.
How can I fix the dotnet build line?
If your publish profile uses MSDeploy, it cannot be built via the .NET Core based build tools (dotnet build).
See the related GitHub issue https://github.com/aspnet/websdk/issues/166
The workaround is to use msbuild /p:Configuration=Release … from a VS 2017 installation instead of dotnet build.

VS2017 MSB4057 The target "CreateManifestResourceNames" does not exist in the project

When VS2017 was used to create a stateful solution, producing the standard boilerplate code, the resulting two projects have two different MSBuild versions.
The application uses MSBuild version 1.5.0.
The service uses MSBuild version 1.6.0 (the current "latest").
If I run the solution this way, it runs fine on my local Service Fabric cluster.
But when after I use NuGet to update the application's MSBuild to 1.6.0 (so both application and server projects use the same), the following errors occur.
Severity Code Description Project File Line Suppression State
Error The OutputPath property is not set for project 'gt_strd5.sfproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' P follow a project-to-project reference to this project, this project has belatform='x64'. This error may also appear if some other project is trying toen unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform. gt_strd5 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 737
Severity Code Description Project File Line Suppression State
Error MSB4057 The target "CreateManifestResourceNames" does not exist in the project. gt_strd5 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 2630
I found that after the change, some references in the application's project file continued to reference MSBuild 1.5.0. In my case, the gt_strd5.sfproj file contained four references which needed to be updated from 1.5.0 to 1.6.0. See the snippets from the XML below.
Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.**MSBuild.1.5.0**\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.**MSBuild.1.5.0**\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')"
.....
Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.**MSBuild.1.5.0**\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.**MSBuild.1.5.0**\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')"
To verify this, I went back a couple times and was able to reproduce both the issue and this solution.
Hope it saves someone else some time.
Best Regards
I was getting this error into PCF control.
Run Developer Command Prompt VS2017/ VS2019
a) Remove white space from your folder like Test%20-%20PCFs (source control generated name) should be TestPCFs
b) Go to pcf project folder from cmd line & run msbuild /t:restore
b) Go to cds project folder from cmd line & run msbuild /t:restore
c) On cds project folder, run msbuild
d) For release deployment run msbuild /p:configuration=Release
For other types of projects
a) Remove white space from your folder name
b) run msbuild /t:restore
c) run msbuild

Resources