Transitive reference in a NuGet package - dll

I have a NuGet Package: My.Framework
This package has a method MyMethod Using Prism
My Package is used in another project MyProject calling MyMethod
Prism <-- My.Framework (MyMethod) <-- MyProject
My problem is when I execute MyProject it fails because the Prism.Dll is not present in the build folder.
Do you know how I can instruct MsBuild to Copy the Prism.Dll in the build folder?
Ideally, I would have the information defined in My.Framework package.
Update
MyFramework Package reference correctly Prism:

You need to ensure your package's dependencies are defined in its nuspec file

Related

Consuming nuget package containing .targets file via PackageReference

I have .NET452 project - lets call it Consumer.csproj that I want to consume nuget lets call it SharedTargets that contained some custom targets files (SharedTargets.targets) from msbuild.
I'm using PackageReference format and now (compared to what it used to be) nuget packages are being restored to shared folder (%userprofile%.nuget\packages), and I'm not sure if it is good idea to reference it via that (doesn't feel right).
Eg:
<PackageReference Include="SharedTargets">
<Version>1.0</Version>
</PackageReference>
<Import
Project="$(USERPROFILE)\.nuget\packages\SharedTargets\1.0\SharedTargets.targets"
/>
Also this works only in VS, running this from command line (msbuild) I'm getting chicken-egg problem:
Confirm that the path in the <Import> declaration is correct, and that
the file exists on disk.
Obviously since I need to restore nuget first before I can use it :)
So question:
is there some more elegant way how to resolve path to the nuget package inside project file
is there a way how to make msbuild succeed (i.e. restore packages before SharedTargets.target is imported)
You shouldn't try to manually import targets distributed via NuGet.
Put your .targets file inside a build subfolder inside the package and name it SharedTargets.targets (package id + .targets) and NuGet will automatically include the targets - for packages.config projects it will modify the project file on install and for PackageReference projects the targets will be imported by modifying an implicitly generated targets file in the obj\ directory.

Publish type declarations outside #types

I have created an npm library but I don't want to publish it in the public repository (So I cannot use #typings npm package to put my typings there). On the other side, I don't want to put .d.ts file into that package but wanted to publish another package called lib-typings.
Is it possible to consume lib-typings for a library called lib in Typescript 2?
As cartant said, property typeRoots in tsconfig.json is for addressing this problem.

Packages.config vs Dependency section in .nuspec file

I am new to nuget and trying got understand where I should define my dependencies. There is the section in my .nuspec file and then there is the list of dependencies in packages.config. What is used when?
When building your assembly, NuGet uses the packages section in the packages.config file to determine which NuGet packages to download.
When installing a package, NuGet uses the dependencies section in .nuspec files to determine which additional NuGet packages to install. Of course, those additional NuGet packages can require their own additional NuGet packages.
When creating a .nuspec file, typically you include one dependency entry for each package entry you find in packages.config (skip package entries with a developmentDependency="true" attribute). But, if you want, you can also skip any package entries that your assembly doesn't reference directly - the indirectly referenced packages should be covered by the dependency entries in the packages that your project does reference directly. In practice, I have found it safer just to include all directly and indirectly referenced packages due to bugs in dependency lists of referenced packages.

Team city build with NuGet packages

I have set up a build in team city, with a NuGet package reference in the test project.
The folder structre I have used is
\
|- Project1
\- Project1.csproj
|- Project1.Test
\- Project1.Test.csproj
|- packages
\- lib
\- RhinoMocks
The Project1 project builds sucessfully, but the Test project fails on the ResolveAssemblyReferences step. The relative path seems to be incorrect.
[13:16:55]: [ResolveAssemblyReference] C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360, 9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Rhino.Mocks, Version=3.6.0.0, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
[13:16:55]: [ResolveAssemblyReference] For SearchPath "{HintPathFromItem}".
[13:16:55]: [ResolveAssemblyReference] Considered "..\packages\RhinoMocks.3.6\lib\Rhino.Mocks.dll", but it didn't exist.
TeamCity build config:
MSBuild task
Build file path: Project1.Test\Project.Test.csproj
Working directory: %system.teamcity.build.checkoutDir%\Project1.Test
VCS root points to the root of the folder structure above.
As far I can tell this may be a MSBuild issue, I get the same error when I run MSBuild at the command line in the checkout folder on the build agent.
More info:
The hint path is being provided by the Nuget package configuration. Within Visual Studio the package reference works correctly. However, when running via MSBuild, it seems confused about its current directory. The ..\packages... path is actually the verbatim reference path from Nuget.
I'm confused about this part of your project structure:
|- packages
\- lib
\- RhinoMocks
This shouldn't be necessary if you're pulling the packages in from NuGet. The only file under "packages" that should be checked into source control is repositories.config.
Also, when TeamCity runs MSBuild, how are you downloading the relevant NuGet dependencies? Is it via the TeamCity "NuGet Installer" or have you configured your Solution/Projects to auto run nuget install?
You've got a mixed reference, with a strong assembly name (the Version etc.) and a hint path. If the assembly is in the GAC on your machine, it will be located even if the hint path is wrong. If it isn't in the GAC on the build machine, it can't be found. Check in your project file and see if the HintPath metadata on the Reference is the correct path (looks like it should be "..\packages\lib\RhinoMocks..." instead of what appears in the output.
That's a bunch of ifs, for any more ideas I'd need to see what's inside the project file that is failing.

Add a postbuild event in a nuget package

I am creating a nuget package and I want it to add a post-build event to my project that will copy some dll files to its target directory.
Is such a thing possible? If so, how would I do it?
Or is there a way to, somehow, embed unmanaged dll's (native C++) in my nuget package and have them copied upon build to the target directory?
Well, I kinda figured it out by putting the unmanaged dll's in a Dependencies folder that I put inside the content directory of the nuget package.
Then my build/deploy process depends on that Dependencies folder. (Copy to output directory)