Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't get <contentfiles> working #2060

Closed
304NotModified opened this issue Feb 5, 2016 · 7 comments
Closed

Don't get <contentfiles> working #2060

304NotModified opened this issue Feb 5, 2016 · 7 comments
Labels
Resolution:ByDesign This issue appears to be ByDesign

Comments

@304NotModified
Copy link

We like to make the NLog.Config / NLog.Schema packages available for ASP.NET5 projects. We like to add a file to the root of the website, e.g. nlog.config.

But we don't get it working. The nlog.config is added to the bin folder, .e.g. C:\Users....dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin

We tried the following nuspec:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
    <metadata>
        <id>NLog.Config</id>
        <version>4.2.3.1</version>
        <title>NLog Configuration</title>
        <authors>Kim Christensen,Julian Verdurmen</authors>
        <owners>Kim Christensen</owners>
        <licenseUrl>http://raw.github.com/NLog/NLog/master/LICENSE.txt</licenseUrl>
        <projectUrl>http://nlog-project.org/</projectUrl>
        <iconUrl>http://nlog-project.org/NConfig.png</iconUrl>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>Empty NLog.config file.</description>
        <summary>Empty NLog.config file for use with NLog.</summary>
        <releaseNotes>NLog 4.2.3 - Visual Studio 2015 compatible. (no Powershell install needed)</releaseNotes>
        <language>en-US</language>
        <tags>nlog xml config</tags>
        <dependencies>
            <dependency id="NLog" version="4.2.3" />
            <dependency id="NLog.Schema" version="4.0" />
        </dependencies>
        <contentFiles>
          <files include="contentFiles\any\any\NLog.config" buildAction="None" copyToOutput="true" flatten="true" />
        </contentFiles>
    </metadata>
    <files>
        <file src="content\NLog.config" target="content\NLog.config" />
        <file src="tools\Install.ps1" target="tools\Install.ps1" />
    </files>
</package>

Tested in VS2015 SP1.

What am I doing wrong?

@emgarten
Copy link
Member

emgarten commented Feb 5, 2016

Paths under <contentFiles> should not include contentFiles, everything is required to be under that folder so it is added for you. You can also use a wildcard to simplify this.

<contentFiles> is applied to the contentFiles folder when the package is consumed. In <files> which is used at creation time the config is only being copied to the content folder.

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
    <metadata>
        <id>NLog.Config</id>
        <version>4.2.3.1</version>
        <title>NLog Configuration</title>
        <authors>Kim Christensen,Julian Verdurmen</authors>
        <owners>Kim Christensen</owners>
        <licenseUrl>http://raw.github.com/NLog/NLog/master/LICENSE.txt</licenseUrl>
        <projectUrl>http://nlog-project.org/</projectUrl>
        <iconUrl>http://nlog-project.org/NConfig.png</iconUrl>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>Empty NLog.config file.</description>
        <summary>Empty NLog.config file for use with NLog.</summary>
        <releaseNotes>NLog 4.2.3 - Visual Studio 2015 compatible. (no Powershell install needed)</releaseNotes>
        <language>en-US</language>
        <tags>nlog xml config</tags>
        <dependencies>
            <dependency id="NLog" version="4.2.3" />
            <dependency id="NLog.Schema" version="4.0" />
        </dependencies>
        <contentFiles>
          <files include="**/*" buildAction="None" copyToOutput="true" flatten="true" />
        </contentFiles>
    </metadata>
    <files>
        <file src="content\NLog.config" target="content\NLog.config" />
        <file src="content\NLog.config" target="contentFiles\any\any\NLog.config" />
        <file src="tools\Install.ps1" target="tools\Install.ps1" />
    </files>
</package>

@emgarten
Copy link
Member

emgarten commented Feb 5, 2016

Note also that contentFiles is only for immutable content. The user will not be able to modify this file and it will be copied to the output folder each time, potentially overwriting user changes.

@emgarten emgarten closed this as completed Feb 5, 2016
@emgarten emgarten added the Resolution:ByDesign This issue appears to be ByDesign label Feb 5, 2016
@emgarten
Copy link
Member

emgarten commented Feb 5, 2016

We're tracking mutable content for project.json separately.

@skyflyer
Copy link

@emgarten, where are you tracking support for mutable content for project.json? Couldn't find it in the issue tracker.

Also, this feature isn't working for ASP.NET 5 project. I've created a simple nuget package with the following spec:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>testing-ci</id>
    <version>1.0.6</version>
    <authors>user</authors>
    <owners>user</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Common templates</description>
    <releaseNotes>This is initial release</releaseNotes>
    <copyright>Copyright 2016</copyright>
    <tags>MVC</tags>
    <contentFiles>
       <files include="**/*" buildAction="None" copyToOutput="true" flatten="true" />
    </contentFiles>
  </metadata>
</package>

and contentFiles folder includes any\any\Views\_ViewStart.cshtml file. But the files present in the archive (and in the contentFiles dir) are not added to the consuming project. Is there a workaround?

@304NotModified
Copy link
Author

I also did not got it working. The specs are unclear where the items will be added. (but did not checked the docs lately)

@neethasp
Copy link

The settings specified by @emgarten do not work for extracting contents from nuget which contains .js files. Please provide working settings for this usecase. Thanks.

@emgarten
Copy link
Member

@neethasp please open a new issue with repro steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution:ByDesign This issue appears to be ByDesign
Projects
None yet
Development

No branches or pull requests

4 participants