4

I am attempting to collect a series of Razor views into a NuGet package using .nuspec <files> elements. My project structure is non-standard, however, for reasons I won't get into, I cannot change it.

Here's my project structure:

* Project
  * Bar
     * code
         * Bar.csproj <-- OctoPack initiated from here
         * Views
             * Bar
                 * View1.cshtml
                 * View2.cshtml
  * Baz
     * code
         * Views
             * Baz
                 * View3.cshtml
                 * View4.cshtml
  * Qux
     * code
         * Views
             * Qux
                 * View5.cshtml
                 * View6.cshtml

... and here is what I'm after:

Desired Result

* Views
    * Bar
        * View1.cshtml
        * View2.cshtml
    * Baz
        * View3.cshtml
        * View4.cshtml
    * Qux
        * View5.cshtml
        * View6.cshtml

Here is what i've tried:

Attempt #1

<file src="..\..\..\Project\*\code\Views\**\*.cshtml" target="Views" />

Strangely, the single wildcard becomes the recursive starting point, resulting in:

* Views
    * Bar
        * code
            * Views
                * View1.cshtml
                * View2.cshtml
    * Baz
        * code
            * Views
                * View3.cshtml
                * View4.cshtml
    ...

Attempt #2

<file src="..\..\..\Project\**\code\Views\**\*.cshtml" target="Views" />

Produces the same result as #1

Attempt #3

<file src="..\..\..\Project\*\code\Views\*\*.cshtml" target="Views" />

Results in the following:

* Views
    * View1.cshtml
    * View2.cshtml
    * View3.cshtml
    * View4.cshtml
    * View5.cshtml
    * View6.cshtml
Derek Hunziker
  • 12,996
  • 4
  • 57
  • 105

1 Answers1

1

If you are building sln file with Octopack, You will need 3 nuspec files named with the same named and located csprojectfilename.nuspec

The section must like the following

Bar.nuspec (Same folder level with Bar.csproj)

<file src="obj\Release\Package\PackageTmp\bin\Views\bar\*.cshtml"     target="Views\Bar"/>

Baz.nuspec (Same folder level with Baz.csproj)

<file src="obj\Release\Package\PackageTmp\bin\Views\baz\*.cshtml"     target="Views\Baz"/>

Qux.nuspec (Same folder level with Qux.csproj)

<file src="obj\Release\Package\PackageTmp\bin\Views\qux\*.cshtml"     target="Views\Qux"/>

There will be 3 nuget packages.

OR (without octopack)

If you want to do this with one nuget package you should use nuget.exe and package manually.

"C:\Scripts\Nuget.exe" pack %WORKSPACE%\Allfilesources.nuspec -OutputDirectory "%2" -BasePath "%3" -version %4

Allfilesources.nuspec

<file src="C:\CustomPack\obj\Release\Package\PackageTmp\bin\Views\bar\*.cshtml"     target="Views\Bar"/>
<file src="C:\CustomPack\obj\Release\Package\PackageTmp\bin\Views\baz\*.cshtml"     target="Views\Baz"/>
<file src="C:\CustomPack\obj\Release\Package\PackageTmp\bin\Views\qux\*.cshtml"     target="Views\Qux"/>
Ozgur Kaya
  • 253
  • 2
  • 7