Problem after transferring files to another system (error NETSDK1) - c#

After I import the files from another system to my system, I get the following error
Severity Code Description Project File Line Suppression State
Error NETSDK1005 Assets file 'C:\Users\user\Desktop\project1\project1\project1\obj\project.assets.json' doesn't have a target for 'net5.0'. Ensure that restore has run and that you have included 'net5.0' in the TargetFrameworks for your project. project1 C:\Program Files\dotnet\sdk\6.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 267

Update to Nuget 5.8 Clear the local cache
error NETSDK1005: Assets file 'project.assets.json' ....
Try updating NuGet.exe to the 5.8.0 version or above:
nuget update -self
if you prefer to update the nuget version in Visual Studio, just follow this steps. Then, clear NuGet cache:
dotnet nuget locals all --clear
reference

Related

Nuget PackageReference found in one solution, but not in my own solution

Previous title:
The "GenerateFileFromTemplate" task was not found
.NET project template - GeneratedContent
.csproj.in file transformations
The troubled package is Microsoft.DotNet.Build.Tasks.Templating.
I've created a git-repository containing multiple .NET project templates. When opened in Visual Studio, VS had a horrible performance when adding more files to the template project. This turned out to be caused by my template's project files having .csproj extension. Therefor I've changed the extensions of all my template csproj files to csproj.in.
Because of this, I need to add a msbuild task that transforms this .csproj.in to .csproj. There are several examples out on the internet:
ASP.NET Core project templates
spa-templates (Seems to use the Arcade SDK)
dotnet-template-samples (very basic)
microsoft/SEAL
In the above samples, there is no nuget.config in the project.
Your root csproj file contains a <GeneratedContentProperties> and <GeneratedContent> section:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<GeneratedContentProperties>
DefaultNetCoreTargetFramework=$(DefaultNetCoreTargetFramework);
</GeneratedContentProperties>
</PropertyGroup>
<ItemGroup>
<GeneratedContent Include="Angular-CSharp.csproj.in" OutputPath="content/Angular-CSharp/Company.WebApplication1.csproj" />
<GeneratedContent Include="React-CSharp.csproj.in" OutputPath="content/React-CSharp/Company.WebApplication1.csproj" />
</ItemGroup>
</Project>
The .csproj.in files reference the GeneratedContentProperties:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
...
</PropertyGroup>
...
</Project>
I've tried applying the same files to my project in this commit, but I'm still getting the following error when building the project:
dotnet build --configuration Release
MSBuild version 17.3.0+92e077650 for .NET
Determining projects to restore...
C:\Program Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets(152,5): warning NETSDK1023: A PackageReference for 'Microsoft.DotNet.Build.Tasks.Templating' was included in your project. This package is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see https://aka.ms/sdkimplicitrefs [C:\repos\MintPlayer.AspNetCore.Templates\MintPlayer.AspNetCore.
IdentityServer.Templates\MintPlayer.AspNetCore.IdentityServer.Templates.csproj]
...
All projects are up-to-date for restore.
...
C:\repos\MintPlayer.AspNetCore.Templates\eng\GenerateContent.targets(27,3): error MSB4036: The "GenerateFileFromTemplate" task was not found. Check the following:
1.) The name of the task in the project file is the same as the name of the task class.
2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface.
3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Program Files\dotnet\sdk\6.0.400" directory
[C:\repos\MintPlayer.AspNetCore.Templates\MintPlayer.AspNetCore.IdentityServer.Templates\MintPlayer.AspNetCore.IdentityServer.Templates.csproj]
Build FAILED.
It seems that dotnet cannot find the GenerateFileFromTemplate Task...
I also see that the spa-templates project is using the Arcade SDK, but I don't think I'd actually need that...
How can I fix this? What am I still missing here?
EDIT
When I open both projects in Visual Studio, this is what I see:
Nuget packages for my template project:
C:\repos\MintPlayer.AspNetCore.Templates\MintPlayer.AspNetCore.IdentityServer.Templates> dotnet restore
Determining projects to restore...C:\repos\MintPlayer.AspNetCore.Templates\MintPlayer.AspNetCore.IdentityServer.Templates\MintPlayer.AspNetCore.IdentityServer.Templates.csproj : warning NU1604: Project dependency Microsoft.DotNet.Build.Tasks.Templating does not contain an inclusive lower bound.
Include a lower bound in the dependency version to ensure consistent restore results.
C:\repos\MintPlayer.AspNetCore.Templates\MintPlayer.AspNetCore.IdentityServer.Templates\MintPlayer.AspNetCore.IdentityServer.Templates.csproj : error NU1101: Unable to find package Microsoft.DotNet.Build.Tasks.Templating. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, Local, Microsoft Visual Studio Offline Packages, nuget.org
Failed to restore C:\repos\MintPlayer.AspNetCore.Templates\MintPlayer.AspNetCore.IdentityServer.Templates\MintPlayer.AspNetCore.IdentityServer.Templates.csproj (in 516 ms).
Nuget packages for spa-templates:
C:\repos\spa-templates\src> dotnet restore
Determining projects to restore...
C:\repos\spa-templates\src\Microsoft.DotNet.Web.Spa.ProjectTemplates.csproj : warning NU1603: Microsoft.DotNet.Web.Spa.ProjectTemplates.7.0 depends on Microsoft.DotNet.Build.Tasks.Templating (>= 6.0.0-beta.21373.11) but Microsoft.DotNet.Build.Tasks.Templating 6.0.0-beta.21373.11 was not found. An approximate best match of Microsoft.DotNet.Build.Tasks.Templating 6.0.0-beta.22212.5 was resolved.
All projects are up-to-date for restore.
So it seems that dotnet restore is unable to restore this package. However, the nuget sources are the same for both projects:
IdentityServer.Templates>dotnet nuget list source
Registered Sources:
1. nuget.org [Enabled]
https://api.nuget.org/v3/index.json
2. Local [Enabled]
C:\packages
3. Microsoft Visual Studio Offline Packages [Enabled]
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
C:\repos\spa-templates>dotnet nuget list source
Registered Sources:
1. nuget.org [Enabled]
https://api.nuget.org/v3/index.json
2. Local [Enabled]
C:\packages
3. Microsoft Visual Studio Offline Packages [Enabled]
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
EDIT 2
Hmm, it seems that GenerateFileFromTemplate is part of the Arcade SDK... (Howto)
How to install Microsoft.DotNet.Arcade.Sdk into the dotnet sdk folder?
It seems that the package is only available through the following NuGet feed:
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json
So I added a nuget.config in the root of the project/repository:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
</packageSources>
</configuration>
And since there's only preview versions of the package, you need for example the following version (eng/Versions.props):
<Project>
...
<PropertyGroup Label="Package versions">
<MicrosoftDotNetBuildTasksTemplatingVersion>6.0.0-beta.21373.11</MicrosoftDotNetBuildTasksTemplatingVersion>
...
</PropertyGroup>
</Project>

Newbie: how to restore nuget packages?

I've downloaded a C# project, based on NuGet packages, but I fail to restore them. Here you see what happens when I ask for restoring those packages: (in top of this, the "Autenticator" app on my smartphone constantly asks me for permission (which I'm giving, of course).
Hereby the results of a NuGet restore in commandline (just for one particular package, there are lots of them:
C:\<Project_Dir>>nuget restore
MSBuild auto-detection: using msbuild version '16.10.2.30804' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin'.
Restoring NuGet package Own_Product.Client.Core.1.52.1961.
...
GET https://api.nuget.org/v3-flatcontainer/Own_Product.client.core/1.52.1961/Own_Product.client.core.1.52.1961.nupkg
...
NotFound https://api.nuget.org/v3-flatcontainer/Own_Product.client.core/1.52.1961/Own_Product.client.core.1.52.1961.nupkg 459ms
...
GET https://Own_Product.pkgs.visualstudio.com/_packaging/Own_ProductNuGetFeed/nuget/v2/Packages(Id='Own_Product.Client.Core',Version='1.52.1961')
...
NotFound https://Own_Product.pkgs.visualstudio.com/_packaging/Own_ProductNuGetFeed/nuget/v2/Packages(Id='Own_Product.Client.Core',Version='1.52.1961') 1252ms
GET https://Own_Product.pkgs.visualstudio.com/_packaging/Own_ProductNuGetFeed/nuget/v2/FindPackagesById()?id='Own_Product.Client.Core'&semVerLevel=2.0.0
...
OK https://Own_Product.pkgs.visualstudio.com/_packaging/Own_ProductNuGetFeed/nuget/v2/FindPackagesById()?id='Own_Product.Client.Core'&semVerLevel=2.0.0 422ms
...
WARNING: Unable to find version '1.52.1961' of package 'Own_Product.Client.Core'.
C:\Users\this_User\.nuget\packages\: Package 'Own_Product.Client.Core.1.52.1961' is not found on source 'C:\Users\this_User\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'Own_Product.Client.Core.1.52.1961' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
https://api.nuget.org/v3/index.json: Package 'Own_Product.Client.Core.1.52.1961' is not found on source 'https://api.nuget.org/v3/index.json'.
https://Own_Product.pkgs.visualstudio.com/_packaging/Own_ProductNuGetFeed/nuget/v2: Package 'Own_Product.Client.Core.1.52.1961' is not found on source 'https://Own_Product.pkgs.visualstudio.com/_packaging/Own_ProductNuGetFeed/nuget/v2'.
...
WARNING: Unable to find version '1.52.1961' of package 'Own_Product.Client.Core'.
C:\Users\this_User\.nuget\packages\: Package 'Own_Product.Client.Core.1.52.1961' is not found on source 'C:\Users\this_User\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'Own_Product.Client.Core.1.52.1961' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
https://api.nuget.org/v3/index.json: Package 'Own_Product.Client.Core.1.52.1961' is not found on source 'https://api.nuget.org/v3/index.json'.
https://Own_Product.pkgs.visualstudio.com/_packaging/Own_ProductNuGetFeed/nuget/v2: Package 'Own_Product.Client.Core.1.52.1961' is not found on source 'https://Own_Product.pkgs.visualstudio.com/_packaging/Own_ProductNuGetFeed/nuget/v2'.
...
For your information:
I'm using NuGet.exe version 5.9.1.11, instead of the standard 2.8.50126.400 one.
The result of Nuget list Own_Product.client.core gives another version than the one I'm seem to be looking for while doing the regular compilation:
C:\<Project_Dir>>nuget list Own_Product.client.core
nuget list Own_Product.client.core
MSBuild auto-detection: using msbuild version '16.10.2.30804' from
'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin'.
Own_Product.Client.Core 20.3.18.1
Since you mention that this is for an internal repository it is likely that you are missing the package source for your internal repo. This is specified in the %AppData%\NuGet\NuGet.config file, and is easiest to edit thru the visual studio package sources dialog
Looking at the error it seems like nuget is looking for the package at api.nuget.org and Own_Product.pkgs.visualstudio.com. The later does not seem look like a real repository for visual studio, so it might be miss-configured.
Since it is an internal repo it is difficult say what the exact settings should be, I would suggest you ask a college to send a copy of the settings they use.

Nuget error when trying to publish in .Net5

When I publish in .Net5 I get the following Errors
Severity Code Description Project File Line Suppression State
Error Assets file 'C:\Users\cornelis.dejager\source\repos\Marel.MSAWebServiceAPI\Marel.MSAWebServiceAPI\obj\publish\win-x86\project.assets.json' not found. Run a NuGet package restore to generate this file. Marel.MSAWebServiceAPI 0
and
Severity Code Description Project File Line Suppression State
Error Failed to retrieve information about 'Microsoft.WindowsDesktop.App.Runtime.win-x86' from remote source 'https://api.nuget.org/v3-flatcontainer/microsoft.windowsdesktop.app.runtime.win-x86/index.json'.
An error occurred while sending the request.
The request was aborted: Could not create SSL/TLS secure channel. Marel.MSAWebServiceAPI 0
What caused it:
Not sure to be honest. After I changed code it stopped working. The project has been fine for weeks now and suddenly it changed.
I have tried
Cleaned solution
Build/Re-Build Solution
Restore The Nuget Packages
Update Visual Studio
Rebuild All projects
Delete Bin & Object folders
Update all packages
Restarting Visual Studio + Computer
Created new publishing profile
install dotnet-WindowsDesktop
Reinstall .Net5 Runtimes
Run the command:
Additional Info
It builds and run fine. Only when I publish it seems to give me an error.
I really do not why publishing isn't working. I've looked at several places but have not found a solution to it yet.
It may happen from the wrong package source,
In Visual Studio go to
Options=> Nuget Package Manager=> Package Sources
if you are using a custom source make sure you have entered the address correctly.
NuGet default source address is https://api.nuget.org/v3/index.json

Azure Service Fabric unable to do CI on VSTS with ASP.NET Core

I have Service Fabric based system created and working on production environment (and development). Everything is ok. Now I was trying to setup CI on Visual Studio Team Services with provided templates for ASF projects.
Unfortunately my system has Actors (.NET 4.5.2) and WebAPI based on ASP.NET Core 1.1. I have references to Actor interfaces project (also .NET 4.5.2) forom .NET Core.
When I'm trying to build project with default template I'm recieving error because dotnet restore was not run. Ok, so I've added step to run dotnet restore but then I'm getting error complaining that it cannot find reference to Actor.Interfaces.
dotnet restore also fails on my dev machine but solution build with VS goes ok.
How can I fix this issue?
[UPDATE]
Thanks Mardoxx, I've made some progress... now I'm getting below error for *.sln buld. My solution is VS2015 (set in build task), I've set env to Hosted VS2017.
IntegrationApi\IntegrationApi.xproj(7,11): Error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\DotNet\Microsoft.DotNet.Props" was not found. Also, tried to find "DotNet\Microsoft.DotNet.Props" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
Project "d:\a\1\s\Labelcall.sln" (1) is building "d:\a\1\s\IntegrationApi\IntegrationApi.xproj" (18) on node 1 (default targets).
d:\a\1\s\IntegrationApi\IntegrationApi.xproj(7,11): error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\DotNet\Microsoft.DotNet.Props" was not found. Also, tried to find "DotNet\Microsoft.DotNet.Props" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
Done Building Project "d:\a\1\s\IntegrationApi\IntegrationApi.xproj" (default targets) -- FAILED.
[UPDATE2]
After taking steps presented by starain-MSFT I'm getting errors during 'dotnet restore':
log : Restoring packages for d:\a\1\s\AdminPanel\project.json...
error: Unable to resolve 'AccountActor.Interfaces' for
'.NETFramework,Version=v4.5.2'.
error: Unable to resolve 'CommonContracts' for
'.NETFramework,Version=v4.5.2'.
error: Unable to resolve 'CommonInfrastructure' for
'.NETFramework,Version=v4.5.2'.
[UPDATE3]
Another update after #starain input.
Now I'm getting error that references (to .NET 4.5.2 projcects from Core projects) could not be found.
Project "d:\a\1\s\LabelcallApplication\LabelcallApplication.sfproj" (2) is building "d:\a\1\s\MobileApi\MobileApi.xproj" (19) on node 1 (default targets).
PrepareForBuild:
Creating directory ".\bin\".
Creating directory ".\obj\Release\".
PreComputeCompileTypeScript:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0\tsc.exe --noEmitOnError --listEmittedFiles
CompileTypeScript:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0\tsc.exe --noEmitOnError --listEmittedFiles
CoreCompile:
C:\Program Files\dotnet\dotnet.exe build "d:\a\1\s\MobileApi" --configuration Release --no-dependencies
Project MobileApi (.NETFramework,Version=v4.5.2) will be compiled because expected outputs are missing
Compiling MobileApi for .NETFramework,Version=v4.5.2
C:\Program Files\dotnet\dotnet.exe compile-csc #d:\a\1\s\MobileApi\obj\Release\net452\dotnet-compile.rsp returned Exit Code 1
MobileApi\project.json(6,44): Warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.DependencyCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0
d:\a\1\s\MobileApi\project.json(6,44): warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.DependencyCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0 [d:\a\1\s\MobileApi\MobileApi.xproj]
MobileApi\project.json(6,44): Warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.PerfCounterCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0
d:\a\1\s\MobileApi\project.json(6,44): warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.PerfCounterCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0 [d:\a\1\s\MobileApi\MobileApi.xproj]
MobileApi\project.json(6,44): Warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0
d:\a\1\s\MobileApi\project.json(6,44): warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0 [d:\a\1\s\MobileApi\MobileApi.xproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): Error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\ContactActor.Interfaces\bin\Release\ContactActor.Interfaces.dll' could not be found
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\ContactActor.Interfaces\bin\Release\ContactActor.Interfaces.dll' could not be found [d:\a\1\s\MobileApi\MobileApi.xproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): Error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\DeviceActor.Interfaces\bin\Release\DeviceActor.Interfaces.dll' could not be found
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\DeviceActor.Interfaces\bin\Release\DeviceActor.Interfaces.dll' could not be found [d:\a\1\s\MobileApi\MobileApi.xproj]
Compilation failed.
3 Warning(s)
2 Error(s)
Time elapsed 00:00:01.7675632
Refer to these steps below:
Create a new build definition with Azure Service Fabric Application template
Change Visual Studio Version to Visual Studio 2015 for Visual Studio Build steps.
Select NuGet Installer step/task, change NuGet version to 3.5.0 in Advanced section.
Select Options tab and change Default agent queue to Hosted
Queue build with Hosted agent. (Not Hosted VS 2017)
All build steps:
NuGet Installer (NuGet restore ***.sln)
.Net Core (dotnet restore)
Visual Studio Build (Build solution ***.sln)
Visual Studio Build (Build solution ***.sfproj)
Copy Files
Delete files
Update Service Fabric App Versions
Copy Files
Publish Build Artifacts

Nuget Packages Installation

I have a solution which has a two projects. In the both the projects I have packages.config file which has the list of packages that the project uses. Whenever I build the solution I'm getting the below error
The command "*\Tools\nuget install \packages.config -o \Packages" exited with code 3.**
(replaced folder path with **)
I have installed all the packages manually using package manager console. The installation is successful. When I build the solution now i'm getting the below error
The command "*\Tools\nuget install \packages.config -o \Packages" exited with code 1.**
I have cleared the cache of packages. Still I get this error. Not sure why the solution build is trying to install the packages.
You can try adding -verbosity detailed to your command *\Tools\nuget install \packages.config -o \Packages to get detailed error message to help you investigate the cause.
This was happening in a new CI build I set up yesterday. The problem was that NuGet.exe wasn't at the specified path.
"exited with code 3." wasn't an error from NuGet.exe but from MSBuild.
If you were using TFS, be sure to include the location of the Nuget package in the Source Settings of build definition. This error can indicate it cannot access the files.

Categories