文件(.cs)不显示为可编辑中的自定义nuget软件包,并添加> gt;引起重复

发布于 2025-02-10 11:42:13 字数 3879 浏览 2 评论 0原文

也许我对此朝着错误的方向发展,但是任何建议都将不胜感激。 Web应用程序(MVC)中的小型Nuget软件包,以便新项目可以更快地启动,快速添加SSO,区域和业务逻辑等功能等。

我正在尝试开发一个可以安装到新的.NET Framework 可扩展,因此一旦安装了软件包,就可以建立路线,区域和验证。

该软件包工作正常,可以将其安装到一个新项目中,并且所有验证,样式和路线都可以正常工作。问题是这些已安装的功能似乎隐藏在包装的.dll或垃圾箱内,而且我似乎无法编辑它们。

我尝试在CSPROJ和/或.NUSPEC清单中添加一些额外的详细信息,以手动将文件推入项目文件结构。不幸的是,这似乎只是在nugets .dll中包含的文件之上创建重复项并导致构建错误。

是否可以在Nuget软件包中实际使用可编辑的.CS文件,而用户可以访问该文件,或者我超过了此软件包的目标?

请参阅下面我的.nuspec清单。

<?xml version="1.0" encoding="utf-8"?>
<package >
  <metadata>
    <id>$id$</id>
    <version>1.1</version>
    <title>$title$</title>
    <authors>$author$</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <license type="expression">MIT</license>
    <!-- <icon>icon.png</icon> -->
    <description>$description$</description>
    <releaseNotes>Initial Release</releaseNotes>
    <copyright>$copyright$</copyright>
    <tags>x</tags>
    <dependencies>
            <group targetFramework=".NETFramework4.8">
                <dependency id="Antlr" version="3.5.0.2" />
                <dependency id="bootstrap" version="5.1.3" />
                <dependency id="jQuery" version="3.6.0"  />
                <dependency id="jQuery.Validation" version="1.19.4"  />
                <dependency id="Microsoft.AspNet.Mvc" version="5.2.9"  />
                <dependency id="Microsoft.AspNet.Razor" version="3.2.9" />
                <dependency id="Microsoft.AspNet.Web.Optimization" version="1.1.3"  />
                <dependency id="Microsoft.AspNet.WebPages" version="3.2.9"  />
                <dependency id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="3.6.0"  />
                <dependency id="Microsoft.IdentityModel.Abstractions" version="6.20.0"  />
                <dependency id="Microsoft.IdentityModel.JsonWebTokens" version="6.20.0" />
                <dependency id="Microsoft.IdentityModel.Logging" version="6.20.0"  />
                <dependency id="Microsoft.IdentityModel.Protocols" version="6.20.0"  />
                <dependency id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="6.20.0"  />
                <dependency id="Microsoft.IdentityModel.Tokens" version="6.20.0"  />
                <dependency id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.12"  />
                <dependency id="Microsoft.Owin" version="4.2.2"  />
                <dependency id="Microsoft.Owin.Host.SystemWeb" version="4.2.2" />
                <dependency id="Microsoft.Owin.Security" version="4.2.2" />
                <dependency id="Microsoft.Owin.Security.Cookies" version="4.2.2" />
                <dependency id="Microsoft.Owin.Security.OpenIdConnect" version="4.2.2"  />
                <dependency id="Microsoft.Web.Infrastructure" version="2.0.0"  />
                <dependency id="Modernizr" version="2.8.3" />
                <dependency id="Newtonsoft.Json" version="13.0.1" />
                <dependency id="Owin" version="1.0"  />
                <dependency id="System.IdentityModel.Tokens.Jwt" version="6.20.0" />
                <dependency id="WebGrease" version="1.6.0"  />
            </group>
        </dependencies>
  </metadata>
    <files>
      <file src="Areas\Admin\AdminAreaRegistration.cs" target="content\Areas\Admin\" />
      <file src="App_Start\Startup.Auth.cs" target="content\App_Start\" />
      <file src="Areas\Admin\Controllers\AdmiNController.cs" target="content\Areas\Admin\Controllers\" />
    </files>
</package>

perhaps I am going in the wrong direction with this, but any advice would be appreciated. I am trying to develop a small nuget package which can be installed into new .NET Framework Web Apps (MVC) so that new projects can start quicker, quickly adding features such as SSO, Areas, and business logic etc.

This then needs to be extendable so once the package is installed, the routes, areas, and auth can all be built upon.

The package works fine, it can be installed into a new project and all the auth, styling and routes work fine. The problem is these installed features appear to be hidden away within the .dll or the bin of the package, and I'm seemingly not able to edit them.

I tried adding some extra details in the csproj, and/or the .nuspec manifest, to manually pushing the files into the projects file structure. Unfortunately this just seems to create duplicates on top of the files encased in the nugets .dll and causes build errors.

Is it possible to actually have editable .cs files in nuget packages which can be accessed by the user, or am I overstepping the goal of this package?

See below my .nuspec manifest.

<?xml version="1.0" encoding="utf-8"?>
<package >
  <metadata>
    <id>$id
lt;/id>
    <version>1.1</version>
    <title>$title
lt;/title>
    <authors>$author
lt;/authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <license type="expression">MIT</license>
    <!-- <icon>icon.png</icon> -->
    <description>$description
lt;/description>
    <releaseNotes>Initial Release</releaseNotes>
    <copyright>$copyright
lt;/copyright>
    <tags>x</tags>
    <dependencies>
            <group targetFramework=".NETFramework4.8">
                <dependency id="Antlr" version="3.5.0.2" />
                <dependency id="bootstrap" version="5.1.3" />
                <dependency id="jQuery" version="3.6.0"  />
                <dependency id="jQuery.Validation" version="1.19.4"  />
                <dependency id="Microsoft.AspNet.Mvc" version="5.2.9"  />
                <dependency id="Microsoft.AspNet.Razor" version="3.2.9" />
                <dependency id="Microsoft.AspNet.Web.Optimization" version="1.1.3"  />
                <dependency id="Microsoft.AspNet.WebPages" version="3.2.9"  />
                <dependency id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="3.6.0"  />
                <dependency id="Microsoft.IdentityModel.Abstractions" version="6.20.0"  />
                <dependency id="Microsoft.IdentityModel.JsonWebTokens" version="6.20.0" />
                <dependency id="Microsoft.IdentityModel.Logging" version="6.20.0"  />
                <dependency id="Microsoft.IdentityModel.Protocols" version="6.20.0"  />
                <dependency id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="6.20.0"  />
                <dependency id="Microsoft.IdentityModel.Tokens" version="6.20.0"  />
                <dependency id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.12"  />
                <dependency id="Microsoft.Owin" version="4.2.2"  />
                <dependency id="Microsoft.Owin.Host.SystemWeb" version="4.2.2" />
                <dependency id="Microsoft.Owin.Security" version="4.2.2" />
                <dependency id="Microsoft.Owin.Security.Cookies" version="4.2.2" />
                <dependency id="Microsoft.Owin.Security.OpenIdConnect" version="4.2.2"  />
                <dependency id="Microsoft.Web.Infrastructure" version="2.0.0"  />
                <dependency id="Modernizr" version="2.8.3" />
                <dependency id="Newtonsoft.Json" version="13.0.1" />
                <dependency id="Owin" version="1.0"  />
                <dependency id="System.IdentityModel.Tokens.Jwt" version="6.20.0" />
                <dependency id="WebGrease" version="1.6.0"  />
            </group>
        </dependencies>
  </metadata>
    <files>
      <file src="Areas\Admin\AdminAreaRegistration.cs" target="content\Areas\Admin\" />
      <file src="App_Start\Startup.Auth.cs" target="content\App_Start\" />
      <file src="Areas\Admin\Controllers\AdmiNController.cs" target="content\Areas\Admin\Controllers\" />
    </files>
</package>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红衣飘飘貌似仙 2025-02-17 11:42:14

我认为这是不可能的,因为nugets已经是编译的代码

另外,Nuget的目标是包装可重复使用的代码,而实际上并不能使它们可以编辑。

您可能正在寻找的是源发电机.NET SDK

I don't think it is possible because NuGets are already COMPILED CODE.

also, NuGet's goal is to package reusable code and really not make them editable.

What you are probably looking for is Source Generators .NET SDK

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文