简体   繁体   中英

Calling user defined functions in Package Manager Console in Visual Studio

I created a default ClassLibrary project in visual studio. Then I added an basic class that has one method in it.

在此处输入图片说明

Then I opened Package Manager console in visual studio. And I run standard Regex replace method on it and it works. 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 ?

在此处输入图片说明

PowerShell needs to load the type first before it can call it.

Add-Type -Path c:\\test\\ClassLibrary1.TestClass.cs

[ClassLibrary1.TestClass]::Replace("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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM