I have a project with a runtime text template, i want to be able to call
mytemplate.TransformCode();
from a different project. I only need access to the mytemplate.cs file it generates and do not want to edit the template in the second project.
I have included the .tt file in the nuget package of the first project and installed the nuget package on the second.
The problem is the actual .tt file is installed into the second project, and then fails to compile due to the assembly reference
<## assembly name="$(SolutionDir)\..\..\bin\LanguageExt.Core.dll" #>
Because they relative path to the assembly is no longer correct.
So I need a way to either suppress installation of the tt file into the second project, and be able to instantiate the mytemplate class file from the dll and call GenerateText()
If that's not possible I'd like to at least be able to use a parameter for the assembly relative path, so I can make sure it builds in both places.
Any ideas?
Right, it's as simple as setting 'Build Action' to 'None' on the tt file
gets coat
Related
I have a PS1 script that I use in all my projects to sign the assemblies. Until now I copied this file over to all my projects. Now I wanted to create a nuget package with the PS1 file.
I created a nuspec file and put the file in "content". Unfortunately nothing happened. Then I tried to put it in lib. Still noting happened. When I restore the package in my project no files where created in this project.
When I analyst the nupkg file with my 7-Zip the file looks OK. The ps1 file was in content, lib respectively.
I didn't found anything to this topic online. Can someone explain to me, how to create such a NuGet-Package?
When a project using packages.config installs a NuGet package, the package's tools\install.ps1 script will run. However, this no longer happens when the project using the package uses PackageReference (such as SDK style projects, used by .NET Core).
Similarly, the files in the content folder of the nupkg are copied into the project on install, but only when the project uses packages.config. PackageReference projects use the contentFiles folder in the nupkg, however the behaviour is different. Those files are copied only on build, not install, for .NET Framework projects and on publish for .NET Core projects. Probably not what you want for signing assemblies.
The feature you probably want to use is including MSBuild props and targets in your package. Note that the props and targets file names must match the package id exactly for NuGet to use them. You probably want to use afterTargets="build" at a guess.
I have added Assembly Definition (.asmdef) to my script folder (my custom unity scripts). Now Unity complains that it cannot find OVRInput class which I've used it in one of my scripts (GameManager.cs):
This OVRInput class is compiled into Assembly-CSharp.dll managed assembly as seen below:
I expect Unity, by default, to see this dependency and resolve it but somehow it doesn't. So I decided to manually add "Assembly-CSharp.dll" to the dependency section (called "Assembly Definition References") of my assembly but Unity gives error that it cannot find such an assembly.
The following is my custom Assembly Definition File (that puts all of scripts in "Scripts" folder into the assembly):
Target platform: Android (Oculus Gear VR)
Unity version 2018.3.13f1.
That's kind of the point
Assembly definitions are (effectively) entirely separate projects (part of the same solution, but separate dlls). This is in fact how they are displayed inside Visual Studio's Solution Explorer.
They're meant to be things you reference in to (like TextMeshPro or JsonDotNet) not out of. As such you cannot reference the main Assembly-Csharp "name space."
The advantage is that when a script file changes only its containing assembly is recompiled, instead of the entire project.
In this case, if you want to reference the Oculus files, you either need to create another assembly definition containing those files (and add it as a dependency of your first assembly) or not use an assembly definition at all.
When running 'nuget pack' on a web project, I get a lot of errors saying that a file named 'content' is already added into the package.
For example:
WARNING: File 'SlowCheetah.Transforms.targets' is not added because the package already contains file 'content'
WARNING: File 'Web.config' is not added because the package already contains file 'content'
Looking into the generated package, I find out that the 'content' file is actually one of the content files (the first one it finds), so the what the warnings are telling me is that every content file in the project is being packaged as 'content'.
Any thoughts?
At the end what I did was creating the file structure for the nuget package and packaging from there rather than from the project itself. I actually got more control for what's included rather than giving the VS folder the full responsibility for that.
Using this as a reference: https://learn.microsoft.com/es-es/nuget/create-packages/creating-a-package
I recommend creating the tools, lib, content and build folder structure and publish into it from the web project. You can adjust the nuspec file with your dependencies.
Almost 2 years using this approach :)
I'm trying to use the simplest and most automated approach possible to create a few NuGet packages from some of our projects, by using the nuget pack [path-to-csproj] method.
For most of the projects I've tried this, the command line tool seems to understand the .Net framework version of the projects and it adds the output dll and xml files to the correct lib folder. In some other project, it is including a .css file to the content folder in the package, I assume because the file has a Content build action.
What exactly does this NuGet command include in the final package and how does it extract this information? Is there a comprehensive documentation on the file extraction from the csproj? I'd like to understand this process so that I can hopefully add my own files to it, like the app.config file and some code contracts assembly files without having to hardcode paths in the nuspec definition.
I have created a T4 template that I want to reuse in several projects using NuGet. This template is based on a custom class so I need to distribute a DLL with the template. The DLL is used by the template during generation, but is not used by the project itself so I do NOT want it added to the target project as a reference.
My .nuspec file includes my DLL and places it in the root of the package which will prevent it from creating a reference and everything works fine if I build my package by hand. Unfortunately, I want to use the "nuget pack" command to automatically pick up the version number. When I run this command and reference the project file, it includes my DLL twice, once in the root (as I specified in my nuspec file) and an additional time in the lib folder (along with everything in the bin folder).
How can I automatically build my NuGet package without including any references. It seems there are several solutions, but I can't figure any of them out:
Let nuget include my DLL in the lib folder, but prevent it from creating the reference. I know I can use the <references> section to reference some DLLs and not others, but in this case I don't want it to reference any. If I leave the <references> section blank it is either ignored or I get an error depending on what level I leave blank.
Prevent nuget from including any DLLs automatically and only include the files in the <files> section of the nuspec file. Unfortunately, I can't figure out how to build the package from the project file without it including my DLL automatically.
Any thoughts?
If you right-click the DLL, you'll probably see that its "build action" is set to "content". Try setting it to "none".