I have created a Windows Application Packaging Project in Visual Studio to package a UWP Application and a Console Application together. Everything in the project compiles just fine, and I am able to create an AppPackage for the UWP application by itself.
However, when I attempt to make an AppPackage for the Windows Application Packaging Project I get the following error:
You can't add both "C:\Users\jhogle.nuget\packages\acr.userdialogs\7.0.1\lib\uap10.0.16299\Acr.UserDialogs\Platforms\Uwp\ActionSheetContentDialog.xaml" and "C:\Users\jhogle\Documents\Git\sMARt\Client\Client.UWP\bin\x86\Release\ilc\Acr.UserDialogs\Platforms\Uwp\ActionSheetContentDialog.xaml" to the output file as "Acr.UserDialogs\Platforms\Uwp\ActionSheetContentDialog.xaml"
I know that Arc.UserDialogs is a nuget package that I am using in the UWP application. However, I don't understand what is causing this file to be added twice.
The UWP app is the only project in the solution that references Arc.UserDialogs. It seems to be trying to add the file in question from both the nuget install location, and the output of the UWP application.
What am I doing wrong here?
Edit:
As per Sunteen Wu's comment, I am adding the contents of ActionSheetContentDialog.xaml They can be found here.
I'm trying to use two NuGet packages in my Visual Studio project which has the same output path; so, when I try to build, Visual Studio gives me
Payload contains two or more files with the same destination path 'MyNugetPackage.dll'
Is it possible to change the output .dll name of a NuGet library? If it's, how can I do this?
Thank you
EDIT: If someone is wondering why I want to load two version of the same package, that's because I'm trying to use ApplicationInsights in WP 8.1 Silverlight and RT projects with some shared code. I'm also using background tasks. The SL app uses the same bgtask as RT, so I need to load at the same time the RT and the SL packages of ApplicationInsights for the SL app.
I previously asked a similar question regarding Visual Studio 2013 but now I'm running into the same problem with Visual Studio 2015 but it seems to work differently, which makes the previous answer not applicable to this question. This is my previous question: Visual Studio 2013 - How to debug a project within a solution
I'm attempting to add a project reference. I have a library I'm working on in a separate solution/project and a console application I want to use to test and debug the library.
I tried: Add Reference > Projects > Solution > Browse
But the open file dialog does not contain .sln files in the filter list and if I force it to display them by typing *.sln and then select the Solution I get:
"Please make sure the file is accessible and that it is a valid assembly or COM component."
What am I doing wrong? How do I properly add a Solution/Project reference?
For me issue was due to difference in Target framework. One was .NET Framework 4.5 and other was .NET Framework 4.5.2
Verify if the Target framework is same for your project and the project reference that you are trying add reference.
(Right click on project -> properties -> Application Tab(Target frame work))
Right click on your solution file in Solution Explorer window, click Add and select Existing Project...
Once the project is a part of the solution, you will be able to add project reference.
In case anyone else runs into this here is something that I found. I had almost the exact same issue in VS 2015. I created a console app and then a class library project but could not add a reference to the class library.
It turns out I didn't create a class library project as I had thought, but rather a class library (package) project. These are different things and I was unaware of what the (package) part meant when I selected it. This is for creating Nuget packages, apparently.
I'm not sure if this is something new to VS 2015 but I had not run across it before and it caused me some grief. The error message ('A reference to ClassLibrary1 could not be added') was totally worthless in trying to debug it.
You should add project to your solution first; after adding project to your solution, you can reference it.
To add an existing project to your solution:
Add reference menu:
Add references dialog:
In order to add a project reference, the project has to be part of the solution.
For me issue was due to a difference in the types of projects. One was a C# Windows forms project and the other project was a C# Universal Windows project.
The Windows Forms project couldn't reference the Universal Windows project. The error was "Unable to add a reference to project "XYZ".
It appears you can have a library shared between both types of projects by folloing this answer: What kind of class library works with both Universal and Winform projects?
I ended up having a different solution. I had three projects in the solution which referenced a NuGet package which was no longer available. I had the library locally but I was unable to add it. I found that because of the BUILD ORDER and DEPENDENCY of my projects, I had to add it to the project that was built first, then I could add it to the projects that were dependent on that project.
I had this problem today and I looked at the configuration manager for the solution. The projects had different platform settings. I made them both Any CPU and rebuilt. Then I could reference the project.
Goal: Startup a ASP.NET MVC 5 project on Mono via Xamarain Studio.
Error after starting server:
Could not load file or assembly 'System.Web.Entity' or one of its dependencies.
Error in Xamarin Studio:
Background: The project was created in Visual Studio 2013 as a default web project. Most of the configuration is out of the box. Code for it can be viewed here on GitHub. I have the latest and greatest Mono and Xamarin Studio as of writing. The .NET Entity Framework is a resolved dependency and there are no build issues noted in Xamarin Studio.
How do I get this project up and running? How do I resolve this dependency?
I know this is an old thread, but I ran across this while starting to port over an MVC project from VS for windows to VS for Mac. I found a better solution was to delete the reference to System.Web.Entity, and add the NuGet package System.Web.Http.Common. Hope it helps.
I was able to work around this problem by getting the System.Web.Entity.dll file from my Windows box. I found mine in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\.
Once I copied that to the bin folder of my project on my Mac, and updated the reference to include a HintPath...
<Reference Include="System.Web.Entity" >
<HintPath>..\bin\System.Web.Entity.dll</HintPath>
</Reference>
the project would build in Xamarin Studio. It still showed the red X next to the reference (yes, even if I specified that it was a local copy and added a HintPath), but at least it could find it.
I ended up getting another error about being unable to load System.Drawing.BitmapSuffixInSameAssemblyAttribute, but hey, small progress!
Wouldn't it be better/easier for you just to replace that old EntityFramework with new one from NuGet, I think that will solve most of our problems with other references
Is EntityFramework.dll copied to your bin? In visual studio you can do the below
I got this error today when trying to open a Visual Studio 2008 project in Visual Studio 2005:
The imported project "C:\Microsoft.CSharp.targets" was not found.
Open your csproj file in notepad (or notepad++)
Find the line:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
and change it to
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
This is a global solution, not dependent on particular package or bin.
In my case, I removed Packages folder from my root directory.
Maybe it happens because of your packages are there but compiler is not finding it's reference. so remove older packages first and add new packages.
Steps to Add new packages
First remove, packages folder (it will be near by or one step up to your current project folder).
Then restart the project or solution.
Now, Rebuild solution file.
Project will get new references from nuGet package manager. And your issue will be resolved.
This is not proper solution, but I posted it here because I face same issue.
In my case, I wasn't even able to open my solution in visual studio and didn't get any help with other SO answers.
For me the issue was that the path of the project contained %20 characters, because git added those instead of spaces when the repository was cloned. Another problem might be if the path to a package is too long.
In my case I could not load one out of 5 projects in my solution.
It helped to close Visual Studio and I had to delete Microsoft.Net.Compilers.1.3.2 nuget folder under packages folder.
Afterwards, open your solution again and the project loaded as expected
Just to be sure, close all instances of VS before you delete the folder.
This link on MSDN also helps a lot to understand the reason why it doesn't work. $(MSBuildToolsPath) is the path to Microsoft.Build.Engine v3.5 (inserted automatically in a project file when you create in VS2008). If you try to build your project for .Net 2.0, be sure that you changed this path to $(MSBuildBinPath) which is the path to Microsoft.Build.Engine v2.0.
I used to have this following line in the csproj file:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
After deleting this file, it works fine.
If you are to encounter the error that says Microsoft.CSharp.Core.targets not found, these are the steps I took to correct mine:
Open any previous working projects folder and navigate to the link showed in the error, that is Projects/(working project name)/packages/Microsoft.Net.Compilers.1.3.2/tools/ and search for Microsoft.CSharp.Core.targets file.
Copy this file and put it in the non-working project tools folder (that is, navigating to the tools folder in the non-working project as shown above)
Now close your project (if it was open) and reopen it.
It should be working now.
Also, to make sure everything is working properly in your now open Visual Studio Project, Go to Tools > NuGetPackage Manager > Manage NuGet Packages For Solution. Here, you might find an error that says, CodeAnalysis.dll is being used by another application.
Again, go to the tools folder, find the specified file and delete it. Come back to Manage NuGet Packages For Solution. You will find a link that will ask you to Reload, click it and everything gets re-installed.
Your project should be working properly now.
I got this after reinstalling Windows. Visual Studio was installed, and I could see the Silverlight project type in the New Project window, but opening one didn't work. The solution was simple: I had to install the Silverlight Developer runtime and/or the Microsoft Silverlight 4 Tools for Visual Studio. This may seem stupid, but I overlooked it because I thought it should work, as the Silverlight project type was available.
In my case, I opened my .csproj file in notepad and removed the following three lines. Worked like a charm:
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" />
ok so what if it say this: between the
gt/lt signs
Import
Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.CSharp.targets"
/
how do i fix the targets error?
I also found that import string in a demo project (specifically "Build your own MVVM Framework" by Rob Eisenburg).
If you replace that import with the one suggested by lomaxx VS2010 RTM reports that you need to install this.
For errors with Microsoft.WebApplications.targets, you can:
Install Visual Studio 2010 (or the same version as in development machine) in your TFS server.
Copy the “Microsoft.WebApplication.targets” from development machine file to TFS build machine.
Here's the post.
This error can also occur when opening a Silverlight project that was built in SL 4, while you have SL 5 installed.
Here is an example error message: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.CSharp.targets" was not found.
Note the v4.0.
To resolve, edit the project and find:
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
And change it to v5.0.
Then reload project and it will open (unless you do not have SL 5 installed).
For me, the issue was the path.. When cloning the project that had a space in the name. The project folder was named "Sample%20-%205" instead of what it should be: "Sample - 5"
Opening the project was fine, but building failed with
Could not find the file:
/packages/Microsoft.Net.Compilers.1.3.2/tools/Microsoft.CSharp.Core.targets
I deleted the obj folder and then the project loaded as expected.
Sometimes the problem might be with hardcoded VS version in .csproj file. If you have in your csproj something like this:
[...]\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets"
You should check if the number is correct (the reason it's wrong can be the project was created with another version of Visual Studio). If it's wrong, replace it with your current version of build tools OR use the VS variable:
[...]\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets"
I ran into this issue while executing an Ansible playbook so I want to add my 2 cents here. I noticed a warning message about missing Visual Studio 14. Visual Studio version 14 was released in 2015 and the solution to my problem was installing Visual Studio 2015 Professional on the host machine of my Azure DevOps agent.
After trying to restore, closing VS, deleting the failed package, reopening, trying to restore, multiple times I just deleted everything in packages and when I did a restore and it worked perfectly.
it seems now that the nuget packages folder has moved to a machine wide global cache, using VS2022
For me the issue was that the solution was to deep into the documents folder and on windows 10 there is a path character limit which was reached. As soon as I moved the solution folder up couple of folders this fixed the issue.