[英]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.