Binaries are added to /bin without a reference, why? - visual-studio

I am using a custom built NuGet package with a set of binaries from DevExpress. Whenever I build the project from Visual Studio, a lot of "extra" DevExpress binaries, that I have not added a reference too, is also added to the bin folder.
I have installed a DevExpress suite of some sort so it might be that some of the GAC'ed binaries are added, but why ? I do not wish to have these binaries cluttering my bin folder.
VS references:
Bin folder:

Might be that assemblies knows its dependencies. The Assembly Explorer show you which:

In addition to Rolf's answer.
If the reference is set to "local" in the project, the dll's will be moved to the output folder (\bin)
In the project those refenrences will have a <private>True</Private> tag:
fx:
<Reference Include="log4net, Version=2.0.8.0, ...>
<HintPath>..\packages\log4net.2.0.8\lib\net40-full\log4net.dll</HintPath>
<Private>True</Private> <-- HERE
</Reference>

Related

syncfusion.compression.base cannot be downloaded because it is not compatible with any project in the solution

Hi, I was working on a solution using Visual Studio. While restoring the Nuget, i got the error "syncfusion.compression.base" is missing. When I tried downloading the Nuget, it gave the message as shown in screenshot. What shall I do now?
When I tried downloading the Nuget, it gave the message as shown in screenshot. What shall I do now?
You need to figure out which project installed the package before in your solution. You can check it with the package.config file.
After download the package syncfusion.compression.base from nuget.org, we could to know this package only have one assembly for .NET framework 46:
After you figure out which project installed this package, you should check the project type and target framework, make sure the target framework is .NET 46 and above.
Besides, if can not find this package in the package.config or project.json, you may need to check if your project file contains HintPath for this package, like:
<Reference Include="Syncfusion.Compression.Base, Version=15.2460.0.40, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Compression.Base.15.2460.40\lib\net46\Syncfusion.Compression.Base.dll</HintPath>
<Private>True</Private>
</Reference>
To determine whether the package is what you need, if not, you need delete it in the project file and delete the package in the packages folder.

Is NuGet automatic package restore in Visual Studio 2015 a fairy tale/mythical beast?

I have been trying to figure out why automatic package restore in Visual Studio 2015 doesn't work.
As I understand it there is nothing to do but check a couple of settings. When you build, it looks for missing packages and downloads them automatically.
I have a solution that has 15 individual projects. The majority of them will not compile because of "missing packages".
I do not have any of the legacy NuGet (.nuget folder etc.) in any of these projects and I have the latest and greatest version of NuGet.
Visual Studio simply will not download the missing files. I deleted the solution package folder and it does re-create and download all of the packages when I build, but each individual project still shows missing references.
If I go to the package manager console and issue a
Update-Package -reinstall
then the packages download and everything works. I'm just wonder why it doesn't do this automatically.
It's supposed to right?
NuGet Restore only restores files in the packages directory, but does not restore files inside your project or modify your project.
For example, if there has a package will add some reference dlls or add some content files into your project. After deleting these reference dlls and content files from your project, it will not be added when restoring this package. This will cause the your project could not find the missing pacakges when compile.
So we need use "Update-Package -reinstall" command to force reinstall the package references and content files into project.
Update the example for sharing projects in a team:
Following is my solution structure, the CommDLL project installed some NuGet packages and entire solution is managed by a source control.
I download this solution on another machine from source control use another user account and install another NuGet packages into the CommDLL project. Then use some content from the new installed package and build the project successful. Please make sure the package dlls has been added into your project and it has been set the correct HintPath in .csproj file.
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
Next, I check in this modified project into the source control. Please make sure you the .csproj file and packages.config file are checked in.
Now I get the latest version on another machine to get the modified content. After check out the latest version from source control, the package references are shown with a warning because the project is not compiled, which means the packages are not restored. Please rebuild this project, it will restore the packages for your project (make sure your Visual Studio 2015 has enable "Allow NuGet to download missing packages" and "Automatically check for missing packages during build in Visual Studio" before rebuild this project).

Visual Studio .Net Core project uses the Typescript v1.8 compiler instead of v2.0

I'm using Visual Studio 2015 Pro, Update 3.
My question is how to instruct VS to use the version of the typescript compiler that I want it to use.
VS is refusing to use the Typescript 2.0 compiler, rather is using 1.8. I have installed, via Nuget in VS, Microsoft.Typescript.Compiler v2.0.3 and Microsoft.Typescript.MsBuild v2.0.3, to no avail.
Looking at the detailed output from MSBuild, I see the following:
Target "PreComputeCompileTypeScriptWithTSConfig" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets" from project "C:\Users[...].xproj" (target "CompileTypeScriptWithTSConfig" depends on it):
Using "VsTsc" task from assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\TypeScript.tasks.dll".
Task "VsTsc"
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe --project "C:\Users[...]\tsconfig.json"
Done executing task "VsTsc".
Done building target "PreComputeCompileTypeScriptWithTSConfig" in project "[...].xproj".
So it appears that VS is using the tsc.exe from the Microsoft SDK.
Anyone know how to instruct VS to use the version of tsc that I want it to use?
#starain I really appreciate your efforts.
Unfortunately your suggestion still doesn't work for me. MSBuild/VS does not use the environment path to find tsc. If it were, it would already be finding the correct version. The correct path (to 2.0.3) is already in the environment, and the incorrect path (to 1.8) is not.
I hadn't seen the link you provided to the issue with nuget. This problem does at least appear to be an issue with the nuget installation.
Aided by setting the MSBuild output to "diagnostic" I have managed to figure out a work-around on my own.
In the .xproj file inside <PropertyGroup Label="Globals"> I inserted the following:
<TypeScriptToolsVersion>2.0.3</TypeScriptToolsVersion>
<TscToolPath>C:\Users\[me]\.nuget\packages\Microsoft.TypeScript.MSBuild\2.0.3\tools\tsc</TscToolPath>
So far, it works beautifully except for one thing: Intellisense appears to still be using 1.8. I will leave that for a separate issue.
This solution could easily, of course, present a problem each time I want to update tsc. But for now it's a lot better than nothing.
You need to remove corresponding imported project from your project file.
Right click your project in VS=>Unload project
Right click your project again in VS=>Edit XXX.csproj
Remove this code:
Microsoft.TypeScript.Default.props:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
Microsoft.TypeScript.targets:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
(Optional) If this code isn’t included in your project file, please add it (related to the code of Step 3)
:
<Import Project="..\packages\Microsoft.TypeScript.MSBuild.2.0.3\build\Microsoft.TypeScript.MSBuild.props" Condition="Exists('..\packages\Microsoft.TypeScript.MSBuild.2.0.3\build\Microsoft.TypeScript.MSBuild.props')" />
<Import Project="..\packages\Microsoft.TypeScript.MSBuild.2.0.3\build\Microsoft.TypeScript.MSBuild.targets" Condition="Exists('..\packages\Microsoft.TypeScript.MSBuild.2.0.3\build\Microsoft.TypeScript.MSBuild.targets')" />
For .net core application, it has issue with that nuget package, the typescript reference in ASP.NET Core projects is through the Microsoft.DotNet.Web.targets. So, it won't work. You can check this link (paulvanbrenk's reply).
To use higher version of typescript compiler, you can install Typescript 2.0 and change environment variable path value to corresponding folder (C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0)

Visual Studio 2015 can't find nuget package references and DLLs in packages folder

I've been given a C# project by someone else. I opened the project and tried to install all the Nuget packages by doing a Update-Package -reinstall.
It downloaded all the packages in the packages folder.
/Projects
/WebApiTest (root folder)
WebApiTest.csproj
WebApiTest.sln
/packages (packages are loaded in this folder)
But the entire project still says that it's missing all the references. I editted the csproj file to see where it tries to load the packages from, and that is:
<ItemGroup>
<Reference Include="Antlr3.Runtime">
<HintPath>packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll</HintPath>
</Reference>
<Reference Include="EntityFramework">
<HintPath>packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
... etc.
So I assume it starts looking in the same directory as the csproj file is in. In that same directory is also the packages folder that has all the DLL files. So the path seems to be right.
Why is my project still not able to load the references?
This post is starting to get old, but as I have encountered this issue myself and fixed it, I'll share a possible solution.
I had to manually uninstall and re-install the packages by right-clicking on the problematic project, Manage NuGet packages..., then uninstall/reinstall from there.
Be careful on the packages version: be sure to grab the same, in case the project isn't using the latest.
A noticeable effect for me after this procedure is that the paths in the csproj file got updated.
Hope it'll help someone :)
Open up the csproj file for your project in a plain text editor and fix the paths for the DLL's. You may see something like:
<HintPath>packages\etc\etc\etc...</HintPath>
I changed those occurrences to:
<HintPath>..\packages\etc\etc\etc...</HintPath>
I pushed this change from the computer that the project was working fine on and pulled them back down on the bad machine and it was no longer an issue.
Note: This wouldn't be an issue if your project file was in the same folder as your packages folder.
Does NuGet successfully restore the packages from the command line?
Try running this from the command line, from the same folder as your solution:
nuget restore WebApiTest.sln
Note, you may need to fully qualify the execution of nuget (e.g. C:\nuget\nuget.exe), or have it in your path.
You may need to download the NuGet executable, if you haven't already.
If that doesn't work, hopefully it will shed some light on why!
What fixed the missing project references for me was to simply:
Close Visual Studio
Delete the "packages" folder where all the nuget packages are stored (probably at your solution-level or else project-level directory)
Open the solution again in Visual Studio
If you have automatic package restore on, just rebuild, else first restore the nuget packages (from the solution context menu) and then rebuild.

Visual studio 2015 nuget package not restoring

I've got a project with multiple nuget projects, when I opened this project with visual studio 2015 I did a nuget restore, but all packages references are still broken. In the packages folder, all the packages have been downloaded. How can I restore the packages? It is important that the versions currently defined stay the same and don't upgrade the packages.
If I unload my project, the references seem good, the package versions match:
<Reference Include="Dapper">
<HintPath>..\packages\Dapper.1.42\lib\net45\Dapper.dll</HintPath>
</Reference>
<Reference Include="EasyNetQ">
<HintPath>..\packages\EasyNetQ.0.49.3.390\lib\net40\EasyNetQ.dll</HintPath>
</Reference>
<Reference Include="FluentScheduler">
<HintPath>..\packages\FluentScheduler.3.1.45\lib\net40\FluentScheduler.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
First navigate to C:\Users\.dnx\packages and delete all packages from this location.
Next, in VS2015 load your project and in the Package Manager Console run dnu restore (you may have to use the cd command to get into the same directory as your project.json file if it doesn't default you to there)
The .nuget folder was missing. For some sort of reason, committing my .nuget folder from the original solution to the projects SVN, and then updating the broken project SVN fixed the problem.

Resources