0

I'm creating a nuget package for my open source project and I've run into an issue that I'd like someone to help me with.

My project is depending on a package called RazorGenerator.Mvc. This is a great package that allows me to compile my Razor views (.cshtml) into my dll.

To enable this functionality, the RazorGenerator.Mvc package seems to consist of a powershell script that adds a file RazorGeneratorMvcStart.cs to my project's App_Start directory. This is fine.

However, since my project is depending on this package, whenever someone installs my nuget package, the same powershell script seems to be run in their project. This is because the RazorGenerator.Mvc package is installed into the user's project alongside my nuget package.

Is there a way to prevent this? I would prefer if this script only runs in my local project to embed my Razor views into my resulting .dll, and not to run in my user's projects.

In other words, my project needs to remain dependent on RazorGenerator.Mvc, but I would like to prevent destination projects to be dependent on it as well (they are already depending on my package). The RazorGenerator.Mvc package has done its job in compiling the Razor views and does not need to be installed into my users' projects.

Hope this made sense. Thanks for any response!

2
  • 1
    This is not possible if the project it is being installed into uses packages.config file. The only way for this to work would be for you to just include RazorGenerator.Mvc assemblies in your NuGet package. Other project formats, such as that used by .NET Core, do not support PowerShell scripts. Commented Feb 13, 2018 at 11:58
  • 1
    Do you use a nuspec to pack the file? it has options to controls which assets are consumed by the referencing projects - the same as PrivateAssets on a PackageReference Commented Feb 13, 2018 at 12:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.