简体   繁体   English

远离维护2个项目(天蓝色与非天蓝色)

[英]Moving away from maintaining 2 projects (azure vs non-azure)

We have an asp.net web app that is hosted in 2 environments, one being hosted on azure and one being a "stand-alone" version, hosted on a company server using IIS. 我们有一个asp.net Web应用程序,托管在2个环境中,一个托管在azure上,另一个是“独立”版本,托管在使用IIS的公司服务器上。 These projects are not identical. 这些项目并不完全相同。 For example, the azure project uses Microsoft.WindowsAzure.Storage.Queue, etc.... 例如,azure项目使用Microsoft.WindowsAzure.Storage.Queue等....

The pain point is this: When we make code changes or enhancements to one project, we have to make the same changes to the other project, which is a huge pain. 痛点是:当我们对一个项目进行代码更改或增强时,我们必须对另一个项目进行相同的更改,这是一个巨大的痛苦。

Any suggestions on a better way to handle and manage this? 有关更好的方法来处理和管理这个的任何建议吗? Some clients want to install our web app on their own server, while others prefer azure. 有些客户希望在自己的服务器上安装我们的网络应用程序,而其他客户则更喜欢azure。

Thanks for your feedback and insight. 感谢您的反馈和见解。

To resolve this kind f issue NuGet comes handy 要解决这种问题,NuGet会派上用场

It makes it easy to integrate any combination of DLLs, JavaScript files or any other thing you can think of, into a project. 它可以轻松地将DLL,JavaScript文件或您能想到的任何其他组合的任意组合集成到项目中。 Even if all you want to share is a customized set of Entity Framework classes in a single DLL, it's easier for the developer to add that DLL to his project through NuGet than to go hunting for that DLL on some file share. 即使您想要共享的所有内容都是单个DLL中的一组自定义Entity Framework类,开发人员也可以通过NuGet将该DLL添加到他的项目中,而不是在某些文件共享上搜索该DLL。 In addition, NuGet allows you to provide searchable, descriptive text with your package so that the developer using the NuGet Package Manager from Visual Studio can know what he's about to add to his project. 此外,NuGet允许您使用包提供可搜索的描述性文本,以便使用Visual Studio的NuGet包管理器的开发人员可以知道他将要添加到他的项目中的内容。 NuGet even simplifies life for the developer when he wants to upgrade to a newer version of your package: He just picks the Update tab in the NuGet Package Manager to find which packages in his project have newer versions. 当NuGet想要升级到更新版本的软件包时,他甚至可以简化开发人员的生活:他只需在NuGet软件包管理器中选择更新选项卡,以查找项目中哪些软件包具有更新版本。

IN your case suppose you have 2 solution which uses same set of code, what you need to do is: 在您的情况下假设您有2个使用相同代码集的解决方案,您需要做的是:

1) Create a nuget pakcage of your common soultion 2) Package it 3) Publish it your solution 1)创建一个共同灵魂的nuget pakcage 2)打包3)发布你的解决方案

In this way you will have more control over your solution, even if you dont want to update the nuget feed its fine with the other solution 通过这种方式,您可以更好地控制您的解决方案,即使您不希望使用其他解决方案更新nuget feed

Here is how you can create a Nuget package 以下是如何创建Nuget包的方法

While you can create a NuGet package from the command line, typing obscure commands isn't my first choice -- I prefer to use a GUI. 虽然您可以从命令行创建NuGet包,但是输入obscure命令不是我的首选 - 我更喜欢使用GUI。 If that's your preference also then your first step is to download the NuGet Package Explorer . 如果这也是您的偏好,那么您的第一步是下载NuGet Package Explorer Once the Package Explorer is downloaded, it will open automatically (you'll also find it in your Start menu under NuGet Package Manager when you want to use it again). 下载Package Explorer后,它将自动打开(当您想再次使用它时,您也可以在NuGet Package Manager下的“开始”菜单中找到它)。

NuGetPackage Manager Explorer splits its screen in two: on the left is a pane displaying the package's documentation (labeled "Package metadata") and on the right is a pane listing the files in your package (labeled "Package contents"). NuGetPackage Manager Explorer将其屏幕分为两部分:左侧是显示软件包文档的窗格(标记为“软件包元数据”),右侧是列出软件包中文件的窗格(标记为“软件包内容”)。 To start creating a new package, pick New from the File menu. 要开始创建新包,请从“文件”菜单中选择“新建”。 After that, you can use either pane, but I'd suggest you start on the left with the Package metadata by entering the documentation the developer will see when he picks your package from the NuGet Package Manager. 之后,您可以使用任一窗格,但我建议您从左侧开始使用Package元数据,方法是输入开发人员从NuGet Package Manager中选择包时所看到的文档。 My reasoning is that, if you start with the documentation, you'll have a chance to revise it after you've added your files to your package and have a better understanding of what your package consists of. 我的理由是,如果您从文档开始,在将文件添加到包中并更好地了解包的内容后,您将有机会对其进行修改。

To create your package's documentation, click on the document icon in the top left corner of the Package metadata pane. 要创建包的文档,请单击包元数据窗格左上角的文档图标。 While there's lots of information you can enter, the four critical items are: 虽然您可以输入大量信息,但四个关键项目是:

Id (which must be unique) Id(必须是唯一的)

Authors (a comma-delimited list of the package's authors) 作者(包装作者的逗号分隔列表)

Title 标题

Description 描述

The Title and Description are what developers will see in the NuGet Package Manager, so you want to provide all the information developers might need to find your package, recognize it and know what it does. 标题和描述是开发人员将在NuGet包管理器中看到的内容,因此您希望提供开发人员可能需要的所有信息,以便找到您的包,识别它并知道它的作用。 Optionally, you can also enter into the Tags textbox any keywords that developers might use when looking for your package that don't appear in your Title or Description. 或者,您也可以在“标签”文本框中输入开发人员在查找未显示在“标题”或“说明”中的包时可能使用的任何关键字。 To save your changes, click the green checkmark in the upper-left corner of the Package metadata pane. 要保存更改,请单击“包”元数据窗格左上角的绿色复选标记。

Creating a nuget package 创建一个nuget包

When a developer adds your package to his project, he'll want the components of your package to go into the right folders in his project. 当开发人员将您的包添加到他的项目中时,他会希望您的包的组件进入他的项目中的正确文件夹。 Therefore, your first task in adding files to your package is to add those folders to your package. 因此,将文件添加到包中的第一项任务是将这些文件夹添加到包中。 For example, I want my JavaScript file to go into the project's Scripts folder in a subfolder called PHVIS. 例如,我希望我的JavaScript文件进入名为PHVIS的子文件夹中的项目的Scripts文件夹。 To add that folder structure to my package, I first need to add a content entry to the Package contents pane: From the Package Explorer Content menu, I select Add | 要将该文件夹结构添加到我的包中,我首先需要向Package content窗格添加一个内容条目:从Package Explorer Content菜单中,我选择Add | New Folder, and from the submenu, I select Content. 新文件夹,从子菜单中选择内容。 The content entry appears in the Package contents pane. 内容条目显示在“包内容”窗格中。

With that entry in place, I'm ready to add the folder structure for my JavaScript file. 有了这个条目,我就可以为我的JavaScript文件添加文件夹结构了。 In the Package contents pane, I right-click on the content entry, select Add | 在包内容窗格中,我右键单击内容条目,选择添加| New Folder, and in the resulting dialog give the folder the name Scripts before clicking the OK button. 新建文件夹,在结果对话框中,在单击“确定”按钮之前为该文件夹指定名称“脚本”。 After the Scripts folder appears under the contents entry, I right-click on it and select Add New Folder to add my PHVIS folder. 在Scripts文件夹出现在内容条目下后,我右键单击它并选择添加新文件夹以添加我的PHVIS文件夹。 Finally, I right-click on PHVIS folder, select Add Existing File, surf to my project, find my JavaScript file and double-click on it to add it to my package's contents. 最后,我右键单击PHVIS文件夹,选择添加现有文件,浏览到我的项目,找到我的JavaScript文件,然后双击它将其添加到我的包的内容中。 Now, when a developer adds my package to his project, he'll find that JavaScript file in his project's Scripts/PHVIS folder. 现在,当开发人员将我的包添加到他的项目中时,他会在他的项目的Scripts / PHVIS文件夹中找到该JavaScript文件。

If you prefer, you can also drag files from Windows Explorer into the Package contents pane. 如果您愿意,还可以将文件从Windows资源管理器拖到“包内容”窗格中。 If you do, Package Explorer will take its best guess at what entry the file should go into. 如果您这样做,Package Explorer将最好地猜测该文件应该进入的条目。 If, for example, I drag the DLL for my HtmlHelper out of Windows Explorer and drop it on the Package Contents pane, Package Explorer pops up a dialog asking if I want to add the DLL to the lib folder. 例如,如果我将HtmlHelper的DLL从Windows资源管理器中拖出并将其放在“包内容”窗格中,则Package Explorer会弹出一个对话框,询问我是否要将DLL添加到lib文件夹中。 Because I do, I just accept the offered choice: My DLL appears in the Package contents pane, nested inside the lib entry. 因为我这样做,我只接受提供的选择:我的DLL出现在包内容窗格中,嵌套在lib条目中。 I could've done the same with my JavaScript file if I hadn't wanted to control the folder and subfolder in which the file appeared. 如果我不想控制文件出现的文件夹和子文件夹,我可以用我的JavaScript文件完成相同的操作。

If you find that your folders aren't nested correctly in the Package contents pane, you can drag them to where you want them. 如果发现文件夹未在“包内容”窗格中正确嵌套,则可以将它们拖动到所需位置。 If you want to check that you've got all of your packages in all the right folders, from the Package Explorer File menu, select Export and pick a folder in the resulting Choose a folder dialog. 如果要检查所有正确文件夹中是否包含所有包,请从“包资源管理器文件”菜单中选择“导出”,然后在生成的“选择文件夹”对话框中选择一个文件夹。 Package Explorer will unpack your package into that folder for you to review. Package Explorer会将您的包解压缩到该文件夹​​中供您查看。

Adding a nuget source 添加nuget源

Now it's time to save your package somewhere that you (and other developers) can find it. 现在是时候将您的包保存在您(和其他开发人员)可以找到的地方。 The easiest solution is to tell Visual Studio to use a folder on a network share when looking for NuGet packages. 最简单的解决方案是告诉Visual Studio在查找NuGet包时使用网络共享上的文件夹。 This is the one part of the process where'll you need the cooperation of the other developer because he'll need to tell his Visual Studio about your new folder. 这是该过程的一部分,您需要与其他开发人员合作,因为他需要告诉他的Visual Studio有关您的新文件夹。 You'll also need to save your package to that folder using the Save option on the Package Manager File menu, of course. 当然,您还需要使用“程序包管理器文件”菜单上的“保存”选项将程序包保存到该文件夹​​。

To get your copy of Visual Studio to search for NuGet packages in your new folder, from the Tools menu, select Options. 要获取Visual Studio的副本以在新文件夹中搜索NuGet包,请从“工具”菜单中选择“选项”。 Then, from the left-hand list in the resulting dialog, expand the NuGet Package Manager choice to display the Package Sources entry. 然后,从结果对话框的左侧列表中,展开NuGet Package Manager选项以显示Package Sources条目。 Select that entry and you'll see your current list of package sources on the right side of the Options dialog (you can also get to this dialog from the Manage NuGet Packages dialog box -- just click the Settings button in the lower-left corner that you've been ignoring). 选择该条目,您将在“选项”对话框的右侧看到当前的包源列表(您也可以从“管理NuGet包”对话框进入此对话框 - 只需单击左下角的“设置”按钮你一直在忽视)

To add your NuGet package folder to Visual Studio, click the plus sign button in the upper-right hand corner of the dialog. 要将NuGet包文件夹添加到Visual Studio,请单击对话框右上角的加号按钮。 This adds a new source item to the list already filled in with some default values. 这会将新的源项添加到已使用某些默认值填充的列表中。 To update those default entries, make sure your new source is selected and enter your values in the textboxes at the bottom of the dialog. 要更新这些默认条目,请确保选中新源,然后在对话框底部的文本框中输入值。 You need to give your source a name (for example, PHVIS Package Source) and a source, which is the full path to your NuGet package folder (for example, C:\\NuGet). 您需要为源命名(例如,PHVIS包源)和源,这是NuGet包文件夹的完整路径(例如,C:\\ NuGet)。

Now, in the Visual Studio Manage NuGet Packages dialog, you'll find your new Package Source listed under the Online tab. 现在,在Visual Studio Manage NuGet Packages对话框中,您将在Online选项卡下找到新的Package Source。 Picking your source will list all the packages in the folder. 选择源将列出文件夹中的所有包。 If you select the All option, you'll even find your package mixed into the resulting list with the packages from the regular NuGet sources. 如果选择“全部”选项,您甚至可以使用常规NuGet源中的包将您的包混合到结果列表中。 When you select your package and click Install, your package will be added to the current project. 选择软件包并单击“安装”后,您的软件包将添加到当前项目中。

Hope it helps, Please reach out to me if you want to discuss further. 希望它有所帮助,如果你想进一步讨论,请联系我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过VS 2015 RC进行非Azure部署 - Non-Azure Deployment through VS 2015 RC VSTS部署到非Azure云平台 - VSTS deploy to non-Azure cloud platform 检测.NET应用程序是在Azure中还是在非Azure环境中运行 - Detecting if a .NET app is running in Azure or on a non-Azure environment 服务总线如何在服务器重启后重新连接(非天蓝色) - Service Bus how to reconnect after servers restart (non-azure) 在非Azure生产环境中,ASP.NET核心中的用户机密存储的推荐解决方案是什么? - What is the recommended solution for user secrets storage in ASP.NET core in non-Azure production environment? 我可以将 Azure.Core 命名空间用于非 Azure 项目吗? - Can I use Azure.Core Namespace for non azure projects? Visual Studio 调试器进入 azure 函数项目上的非用户代码 - Visual Studio debugger stepping into non user code on azure functions projects 远离主要构造者 - Moving away from primary constructors Static 与 Azure 函数中的非静态类和方法 - Static vs non-static classes and methods in Azure Functions 从不同项目访问Windows Phone上的Azure移动服务 - Accessing Azure Mobile Service on Windows Phone from Different Projects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM