简体   繁体   English

在Visual Studio的Package Manager控制台中调用用户定义的函数

[英]Calling user defined functions in Package Manager Console in Visual Studio

I created a default ClassLibrary project in visual studio. 我在Visual Studio中创建了一个默认的ClassLibrary项目。 Then I added an basic class that has one method in it. 然后,我添加了一个具有一个方法的基本类。

在此处输入图片说明

Then I opened Package Manager console in visual studio. 然后,我在Visual Studio中打开“程序包管理器”控制台。 And I run standard Regex replace method on it and it works. 我在其上运行标准的Regex替换方法,它可以工作。 Then I try to run my own replace method but it didnt work. 然后,我尝试运行自己的替换方法,但没有成功。 Is there any way to run user defined methods on Package manager console or is it only allowed by core libraries on windows ? 有什么方法可以在Package Manager控制台上运行用户定义的方法,还是只能由Windows上的核心库允许?

在此处输入图片说明

PowerShell needs to load the type first before it can call it. PowerShell需要先加载类型,然后才能调用它。

Add-Type -Path c:\\test\\ClassLibrary1.TestClass.cs 添加类型-路径c:\\ test \\ ClassLibrary1.TestClass.cs

[ClassLibrary1.TestClass]::Replace("testx","x","y") [ClassLibrary1.TestClass] ::替换( “testx”, “X”, “y”)的

You could also put the add-type call into your NuGet_profile.ps1 , and load your DLL if there will be multiple classes you need to call. 您还可以将add-type调用放入NuGet_profile.ps1中 ,如果需要调用多个类,则可以加载DLL。

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

相关问题 Visual Studio - 包管理器控制台 - 以编程方式运行命令 - Visual Studio - Package Manager Console - Running commands programmatically 在Visual Studio中使用程序包管理器控制台中的git - Using git from Package Manager Console in Visual Studio 在 Visual Studio 外使用 NuGet 包管理器控制台运行实体框架迁移 - Using NuGet Package Manager console outside Visual Studio to run Entity Framework Migrations 减少Visual Studio nuget程序包管理器中的超时 - Reduce timeout in Visual Studio nuget package manager 找不到套件管理员控制台 - Package Manager Console not found 无法在Visual Studio 2015 Nuget包管理器中安装包“Microsoft.AspNet.Razor 3.2.3” - Could not install package 'Microsoft.AspNet.Razor 3.2.3' in Visual Studio 2015 Nuget package manager 是否将开发人员定义的构建参数存储在Visual Studio用户文件中? - Store developer-defined build parameters in Visual Studio user files? 如何在Visual Studio编辑器中处理用户定义的页边距中的用户定义的字形? - How to handle a User defined Glyph in a user defined Margin in the Visual Studio Editor? Visual Studio中的调用约定 - Calling Conventions in Visual Studio 是否有视觉工作室的标签管理器? - Is there any tab manager for visual studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM