The command "nuget pack..." exited with code 1 - asp.net

I'm' trying to execute a post build event that builds a nuget package based on a .nuspec file. I'm using Visual Studio 2013. My post build event command line is:
nuget pack $(ProjectPath) -Symbols -Properties Configuration=$(ConfigurationName) -IncludeReferencedProjects
When I build my project, I get the following error:
The command "nuget pack C:\Users\user\Documebts\Code\BookProject\BookProject.Nuget\
BookProject.Nuget.csproj -Symbols -Properties Configuration=Debug
-IncludeReferencedProjects" exited with code 1.
I'm not sure what's going on - I changed the Visual Studio build output to Diagnostic and found this:
>Using 'BookProject.nuspec' for metadata. (TaskId:44)
>Access to the path 'C:\BookProject.1.0.3.4.nupkg' is denied. (TaskId:44)
>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4714,5): error MSB3073: The command "nuget pack C:\Users\user\Documebts\Code\BookProject\BookProject.Nuget\ BookProject.Nuget.csproj -Symbols -Properties Configuration=Debug -IncludeReferencedProjects" exited with code 1.
>Done executing task "Exec" -- FAILED. (TaskId:44)
>Done building target "PostBuildEvent" in project "Miw.Mshdf.Net.Nuget.csproj" -- FAILED.: (TargetId:72)
If I open up a command prompt and type in the post build event command, it works fine and builds the nuget package without any problems. Any ideas?

According to the error code, your problem should be related to the access permission for the path "C:\". Please run your Visual Studio as administrator to make sure it has enough permissions to do any operations.
And make sure your current Windows user also has enough permissions to access the "C:\".

The work around i used is
1. Right click on solution -> manage nuget package for solution
2. On top there is text "install missing packages" -> click restore
3. Also i manually given the package sources in -tools ->Nuget package manager ->
package sources
4. run VS 2013 in administrator mode and gave permission to the required folders

Related

New project xamarin.form prism Error NETSDK1004 - Prism 2.2.1

when generating a new project xamarin.form prism I get this error when running. With the previous version 2.1.7 it worked for me OK.
It does not allow me to open the Nuget Package since it also gives an error.
Any recommendation?
I saw the 2 posts of this error but they do not apply to me.
Error NETSDK1004 Assets file 'C:\Empresas\Job_Facu\Job\Job.Prism\Job.Prism\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. Job.Prism C:\Program Files\dotnet\sdk\3.1.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 234
The error tells you what to do. Run a NuGet restore. Visual Studio should help you do this automatically. Note that if this occurred after updating dependencies sometimes Visual Studio gets confused and it's best to close Visual Studio and reopen it. This usually gets it to refresh itself so you get the updated package restore.
If that's not working for you, you can download the latest nuget.exe and from the command line navigate to the solution directory and execute the command {path to nuget.exe} restore.
When NuGet performs a restore it generates the project.assets.json file in the obj folder of each project it has restored. This in turn provides MSBuild with the reference information it needs to properly reference your dependencies like Prism and Xamarin.Forms.
I have recently ran into similar issue as well, seemingly out of the blue. I believe upgrading my build machine to the latest VS version (VS for Mac 8.10.4 (build 11))
NETSDK1004: */project.assets.json' not found. Run a NuGet package restore to generate this file.
To fix, I had to run Nuget Restore twice. Once for the shared project directory and once for the iOS project.
If I run the restore just for the Shared/(main.sln file) project directory I get the error.
If I run the restore for the iOS project the build passes but IPA file isn't created.
Need to run both.
Modules used for CI/CD build in Azure Devops Pipeline

MSBuild not compiling with both /p:Configuration=Release and -p:Configuration=Debug

We are attempting to install a clean build of the newest version of Kentico (12) on Azure, using Kudu, in DEBUG configuration. We traditionally accomplish this by setting SCM_BUILD_ARGS to -p:Configuration=Debug, and all is well. But for some reason in this newer version, the project fails to compile, and I see that this is the command being run:
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "C:\Users\User\Documents\GitHub\Project\CMS\CMSApp.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="C:\local\Temp\8d6d315018f5ff9";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="C:\Users\User\Documents\GitHub\Project\.\\" -p:Configuration=Debug
Notice both Configuration=Release and Configuration=Debug. The compilation errors are things like Invalid expression term 'string' on the following line of code:
bool licenseOK = LicenseHelper.CheckLicenseLimitations(FeatureEnum.Ecommerce, out int skuCount, out int maxSKUCount);
This doesn't highlight at all in Visual Studio in Debug or Release mode. I am also able to reproduce locally (as shown in my paths above), and if I change the two configurations to both be the same (regardless of whether I choose Debug or Release), it compiles just fine.
What I know I can do is create my own custom deployment command script file as a work-around, but I guess I don't understand why the above MSBUILD command isn't working in the first place.
Any ideas as to why this would work great for all of my ASP.NET projects prior to this one? One thing I know is that Kentico recently included the Roslyn compiler, which I am unfortunately not that familiar with - could that be part of the issue?
UPDATE #1: It appears all of the compilation errors have to do with code that is only valid in C# 7.0. That could be a clue.
It all came down to the fact that the newer versions of Kentico had code that was only valid in C# 7, and required MSBuild 15 to compile. Here's how I was able to set up Kudu:
Add a file named .deployment in the root of my repo, containing only the contents below. This tells Kudu to use a custom deployment script.
Download the deploy.cmd file from my Azure App Service via FTP to the root of my repo, and update it per https://github.com/projectkudu/kudu/issues/2350#issuecomment-373817740 to use the MSBuild 15 path. Details below.
.deployment file contents
[config]
command = deploy.cmd
deploy.cmd updates
1 - Add -MSBuildPath "%MSBUILD_15_DIR%" to nuget call. Example:
nuget.exe restore "{your .sln file path}" -MSBuildPath "%MSBUILD_15_DIR%"
2 - Replace %MSBUILD_PATH% with %MSBUILD_15_DIR%\MSBuild.exe in both occurrences under step 2. Build to the temporary path
This was all that was needed in order to get the build to complete.
As Keith mentions, it was a compatibility issue with C# 7.0 that Kentico 12 uses. This SO thread mentions that you need to run MSBuild version 15 for C# 7.0 code. I ran a similar debug command for my local Kentico 12 project using MSBuild 15, and it succeeded.

Error "dotnet : Could not find any project in `C:\**." when running "dotnet add package Microsoft.AspNetCore.Authentication.MicrosoftAccount"

I have visual studio 2019 and i created a new asp.net core 2.2 project. now i am following these steps Configure Microsoft Account Authentication to enable external login to our web application. but when i run this command:-
dotnet add package
Microsoft.AspNetCore.Authentication.MicrosoftAccount
i got this error:-
PM> dotnet add package
Microsoft.AspNetCore.Authentication.MicrosoftAccount dotnet : Could
not find any project in C:\Users\*****\source\repos\MSlogintest\. At
line:1 char:1
+ dotnet add package Microsoft.AspNetCore.Authentication.MicrosoftAccount
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Could not find ...\MSlogintest`.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError Usage: dotnet add package [options]
Arguments: The project file to operate on. If a
file is not specified, the command will search the current directory
for one. The package reference to add.
Options: -h, --help Show command line help.
-v, --version The version of the package to add. -f, --framework Add the reference only when targeting a specific framework. -n, --no-restore
Add the reference without performing restore preview and compatibility
check. -s, --source The NuGet package source
to use during the restore. --package-directory The
directory to restore packages to. --interactive
Allows the command to stop and wait for user input or action (for
example to complete authentication).
as follow:-
and when i access the folder, i found that there is a VS project folders, as follow:-
so why the error is saying that it can not find any project?
can anyone advice on this error please?
Thanks
I encountered the same issue and found the fix. First of all, read the error message completely and carefully. It says:
"Could not find any project ...."
Which means it was expecting the project information. If you further watch the message closely, it has mentioned the correct usage of this command i.e.
Usage: dotnet add <PROJECT> package [options] <PACKAGE_NAME>
In the argument, enter your project name and run it again. This time, you should see the success message similar to:
info : Adding PackageReference for package 'Microsoft.xxxxxxxx.xxxxxxxx' into project 'C:\Users\xxx\source\repos\ProjectFolder\xxxxxxxx.csproj'.
Got this working on powershell (no IDE). The solution was somewhere hidden in the comments but here is the easy one:
dotnet add <project> package <packageName>
In this case I believe it would be:
dotnet add ContosoUniversity package Microsoft.AspNetCore.Authentication.MicrosoftAccount
cd into the particular project you want to add the package to and type your dotnet command again
> cd project Directory
> dotnet add package Microsoft.AspNetCore.Authentication.MicrosoftAccount
Had the same problem, when i was fiddling around with the nuget commandline it at some point proposed i should retry with elevated privileges.
Specifically i tried manually pointing it one level deeper in the folder structure. (As suggested by DavidG)
I thought: okay, weird, but i am out of good ideas, so lets try that one.
Restarted as administrator, worked.
And by it worked i mean it just worked, no manual fiddling involved. I just used the graphical package manager option that just somehow became available.
So my best guess is i somehow messed up something when installing visual studio. Because i already tried just creating a new project.
Nuget option as admin
You may be clicking on the wrong tab on the nuget site. Make sure you select Package Manager tab. The error you get happens when you click on the .net cli tab and use it in the package manager console window.
Try this in your command terminal, you should into a directory project:
dotnet add package <package.name>
This command is for .NET core. I used it for an old project because it's the first one shown on nuget.org.
The old command should be like this:
Install-Package [package name]

A product matching the following parameters cannot be found during VS Installation

I've tried all the solution available at StackOverflow and VS developer community but I'm unable to resolve the error saying.
A product matching the following parameters cannot be found:
channelId: VisualStudio.15.Release
productId: Microsoft.VisualStudio.Product.Community
Here are the solutions that I've tried.
tried deleting the VS folder in Program Files
tried running InstallCleanup.exe -i with cmd (as administrator)
tried running InstallCleanup.exe -f with cmd (as administrator)
tried deleting VS packages from Program Data
tried installing with new and old both packages
I had this problem and was able to solve with following steps
Open a command prompt with admin privileges
Run following command (this will clean up previous install cache. -full option is important)
"%programfiles(x86)%\Microsoft Visual Studio\Installer\resources\app\layout\InstallCleanup.exe" -full
Restart the installer
Hope this helps. Just to add, I did not have to uninstall VS 2015 for this to work.
Follow these steps and your issue will be resolved:
UNINSTALL
Please navigate to C:\Program Files x86 and search for a Microsoft Visual Studio folder. Then right click and delete that folder.
Then remove only Visual Studio folders from these 2 locations, if they are there:
C:\Users\YOUR_USER\AppData\Local\Microsoft
C:\ProgramData\Microsoft
Lastly, please type regedit in the lower left search field to access the registry editor... Once it's open navigate to HKEY LOCAL MACHINE > SOFTWARE > MICROSOFT and check for a Visual Studio folder there. If you see one there, right click and delete the folder.
BEFORE INSTALLING AGAIN
Before you attempt your installation again, make certain you are following these guidelines below:
Restart.
Make sure your Windows is up-to-date, check for any pending Windows Updates.
Disable any anti-virus/firewall temporarily (this includes Windows Defender). Installer needs unblocked access to the internet to access Microsoft Servers.
Clean up the (C:\Windows\Temp) folder.
When launching the Installer, Right Click and select "Run as Admin"
Overlooking the above steps results in most installations failures.
For people looking for solutions to VS2019 issue, The InstallCleanup.exe is under "Installer" directory instead of its subdir.
"C:\Program Files (x86)\Microsoft Visual Studio\Installer\InstallCleanup.exe" -full

NuGet command line has been stopped working

i cant built a solution, and this errors occurs ,
the error window is given below. how can i solve this error.enter image description here
This error usually happen when one or more file that you used in your nuget in current project is missing or corrupted.
Try Restoring :
Tools > NuGet Package Manager > Package Manager Console command.
Type Update-Package -Reinstall
or
Update-Package -Reinstall -ProjectName myProj
Usually it happens when you do multiple task simultaneously in the IDE.
At the status bar , it says rebuild are started...
Another problem is with your nuget command-line console ,
you need to enter the command after u see the PM> at the console , while your command is 'INSTRUCTION'
I installed .Net framework 4.5 it is working for me

Resources