Creation of Release Build Failed in UWP - visual-studio

I am trying to build a UWP project in Release. But i am not able to create the build and I am getting an error could not copy the file "C:\Users\kumara krishnan\.nuget\packages\System.Private.Uri\4.0.0\runtimes\win8-aot\lib\netcore50\System.Private.Uri.dll" because it was not found. Also I am able to build and deploy when i keep it in debug mode. How to fix this issue?

It seems there is something wrong with your .nuget environment. You can try following steps to fix it.
Firstly delete the whole System.Private.Uri folder under C:\Users\kumara krishnan\.nuget\packages\.
Then in Visual Studio, open the Visual Studio Options dialog, click on the "NuGet Package Manager" node and make sure you have checked "Allow NuGet to download missing packages" and "Automatically check for missing package during build in Visual Studio".
After this, you can just rebuild your project and Visual Studio will automatically restore the NuGet packages your project used and download whole "System.Private.Uri" files.
You can also create a blank app and create a new instance of Uri without adding other references manually to check your environment.

Related

How do I fix the NuGet Package Manager not opening/working?

I have Visual Studio Professional 2019, and I'm working on debugging a project that has issues with its NuGet packages. The NuGet Package Manager button is present when right clicking the solution.
But when I click the button, nothing happens. Nothing opens. Absolutely nothing, no error code, no messagebox, no warning in the debugger. I've tried uninstalling and reinstalling my NuGet extensions, nothing changed. I uninstalled and reinstalled visual studio and made sure to enable the package manager, nothing. I restarted my computer and Visual Studio, nothing.
The thing is, I tried opening another project (this time one of my own), and the package manager works fine, which leads me to believe the guy who made this program disabled the package manager entirely, but somehow kept the button there? I don't know exactly what the hell he did, but right now I'm not able to actually work into getting the packages I need to even launch the program. I can't look at ANY part of it either until the packages are added, because Visual Studio won't display anything.
Projects and solutions can't change the Visual Studio menu options themselves. This issue might occur for you if you are missing a .sln file for your project or if it has become corrupted (you don't actually need a .sln file to open a project in Visual Studio). If you notice, Visual Studio's NuGet Package Manager option in the menu says
Manage NuGet Packages for Solution
(emphasis mine). If you don't have the .sln file and associated properties file, then Visual Studio can't do anything when you click on that menu... there is no 'Solution' (.sln file) for it to manage packages for, in essence
Check the original working repository of the code where the project was created and look for a .sln file and a .vssscc file, and copy those over to your new working repository and open the project via that .sln file, and NuGet Package Manager should open successfully now.
If you can't find them or if the working repository doesn't exist anymore, then you'll need to create a new solution in Visual Studio and import/copy all the project files into the new solution. I don't know of a way to 'rebuild' or 'recreate' a solution file and solution properties file for a project that doesn't have them anymore.
For reference, I have had this issue when running VS on a new computer and opening projects I created, so it is not necessarily some form of 'sabotage'.
Though perhaps not the case for the original question asker, one cause of the "NuGet Package Manager" just won't open issue is a syntax error in the project's packages.config file.
In my case, a merge conflict I didn't notice added merge text (the "<<<<<.." type stuff) to the config file. That lead to a silent read error, which I didn't notice until I opened the actual NuGet Package Manager Console.
This issue occurred for me when I opened a project directly. When I instead opened the project by opening a saved solution (*.sln file) that contained the project, it went away.
In my situation, the problem was duplicated targets in the Sdk Style projects.
I imported an AssemblyInfo.Pack.Common file that defined a PreBuild and PostPack target into a Sdk Style project. But these were also present in the project file itself. The solution was to remove that targets from the project file.
In my case, I was using Visual Studio 2022 and my project was targeting .NET Framework 4.6.2.
I resolved it by removing duplicate package reference in my packages.config file which happened out of merge.
From,
<package id="Microsoft.IdentityModel.Tokens" version="6.25.0" targetFramework="net462" />
<package id="Microsoft.IdentityModel.Tokens" version="6.25.1" targetFramework="net462" />
To,
<package id="Microsoft.IdentityModel.Logging" version="6.25.0" targetFramework="net462" />
This now opens the Nuget Package Manager for my project.

Multiple "No resource found..." and "Error receiving parent for item" for fresh Xamarin project in VS 2017

I have created a new project for Xamarin in Visual Studio 2017 Community Edition 15.8.3. Then I added a few changes in the MainPage.xaml and cs and now I am getting these error on building the solution.
The errors refer to styles.xml which I didn't touch.
I was seeing this error earlier which required required restarting VS, rebooting computer, cleaning obj and bin directories, upgrading VS, etc.
I prefer to not do such things blindly.
Is there any systematic solution for this problem?
See if you have not change any of this in the MainPage.xaml
If not put here your content in that page just to see if anyone see the error.
This worked for me in a VS2017 cross-platform solution targeting Android 7.1:
Clean your project and rebuild it.
Change each XAML file properties:
Change the Build Action from "Embedded Resource" to "Compile" or "C# compiler"
Rebuild your project (it will produce errors)
Close VS2017 and delete the .VS folder and reopen solution
Change each XAML file properties:
Change the Build Action back to "Embedded Resource"
Rebuild and it was good for me.
On a separate project, the solution above did not resolve my errors and I also performed these additional steps with success:
Using this guide, I was able to determine that I was missing the following Nuget reference:
Xamarin.Android.Support.v7.AppCompat
After clean and build, close, delete .VS folder and reopen... I checked the log again and was able to determine that I was missing the following Nuget reference:
Xamarin.Android.Support.Design
Another clean and build and those problems went away... leaving me with remnant code issues that I was able to resolve.
After another clean and build... I received another error that I was missing the following Nuget reference:
Xamarin.Android.Support.v7.CardView
Another clean and build... no errors.

Visual Studio references not resolved until clicked on

References (specifically from internal nuget server) seem to be unresolved after using restore nuget packages. The project builds fine but anything that uses these references show as errors in the code until you manually expand references and click it (shows a warning on the reference, when clicked it resolves and removes warning).
Is there an easy way to auto resolve them without going through every project and clicking the refrerence manually?
Is there an easy way to auto resolve them without going through every project and clicking the refrerence manually?
Please try to use the NuGet command line in the Package Manager Console:
Update-Package -reinstall
to force reinstall the package references into project.
NuGet Restore only restores files in the packages directory (\packages folder ), but does not restore files inside your project or otherwise modify your project.
Check the similar issue for some more details.

the target "UpdateDesignTimeXaml" does not exit in the project error in Xamarin Studio

I am new to mobile application developing. When I was creating a new .xaml file in new solution in the Xamarin Studio.
It gave the error:
"the target "UpdateDesignTimeXaml" does not exit".
How can I resolve this problem?
Build errors can occur if you have updated the Xamarin.Forms nuget to a newer version that requires UpdateDesignTimeXaml.
Close and reopen Xamarin Studio.
Clean all and ReBuild your project.
Ref: https://forums.xamarin.com/discussion/49152/problem-initializecomponent-and-pcl
A workaround for this is to remove the MSBuild:UpdateDesignTimeXaml from the Custom Tool of the xaml file properties in VS. Save, add MSBuild:UpdateDesignTimeXaml again and save again will force MSBuild to recreate the *g.cs file.
I had this with Visual Studio for Mac.
I fixed it by:
closing VS
manually deleting the packages, bin and obj folders
restart the project in VS
restore NuGet packages, build and run.
Got same issue in Visual Studio for Mac. Worked find with
closing VS
manually deleting the packages, bin and obj folders in both android folder and main folder
restart the project in VS
restore NuGet packages, build and run.

How to download build files from Visual Studio Online?

I am a newbie in Visual Studio and have my projects deployed on Visual Studio Online. How can I download the successful build files from Visual Studio Online to my machine. Because as far as I know, after successful completion of the build, we can only download logs as zip file.
I know it is a bit late to answer this question, but in case someone still looking for solution, I used this one:
When creating build definition, in "Build Defaults" pane selected "Copy build output to the following Source Control folder".
In textbox I typed "$/[Your project root]/Drops" where [Your project root] is the root name of your project base.
After that I can build with this definition and in "Drops" folder start appearing folders with build results.
I know this old but I just had this problem. Assuming you have a task of "Publish Artifacts". You can click on the result of a build and there will be an Artifacts tab that let you download the folder created in the publish artifacts task mentioned.

Resources