AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 24.06.2015, 06:30   #1  
Blog bot is offline
Blog bot
Участник
 
25,607 / 848 (80) +++++++
Регистрация: 28.10.2006
In most of my JavaScript client extensibility demos, I develop the whole content of my resource ZIP files inside Visual Studio. When I press F6, magically my NAV gets updated with the latest version of JavaScript that I just wrote. So, how do I do that?

Here’s the cookbook.



There are three things you need to have for this to work. First is NAV, or better yet C/AL based. Another one is about PowerShell. And the last one, of course, is about Visual Studio.

Let’s go to the NAV end first.

I have a codeunit which registers my controls. Something like this:



This local RegisterControl functions receives all information about control add-ins it needs to register, then it creates (or updates) the Client Add-in record. It also imports the Resource.zip file if you provide a path to one.

So far, so good.

Obviously, what I need to do from Visual Studio when I build my solutions is to invoke this codeunit. How can Visual Studio do that? Simply, through PowerShell. So, let’s take a look at the PowerShell scrip(let) that does that. It’s simpler than you would expect:

Import-Module 'C:Program FilesMicrosoft Dynamics NAV80ServiceMicrosoft.Dynamics.Nav.Management.dll'Invoke-NAVCodeunit -ServerInstance DynamicsNAV80 -CodeunitId 50001 -MethodName RegisterControls -Argument "C:Temp"

Yes, it has some hardcoding inside, I could have done it better, but for the sake of the example, it’s good enough.

Now, the last part, the Visual Studio.

In my Visual Studio project properties, I have defined post-build event command lines that do the following:
  1. Execute VsDevCmd.bat batch file that references the paths to important command-prompt utilities of Visual Studio and .NET
  2. Delete the Resource.zip file from my project directory
  3. Call 7z.exe (from 7-Zip product) to zip the content of my Resource directory into the Resource.zip file
  4. Copy the Resource.zip into a temporary location
  5. Execute the PowerShell script to register the control add-ins and import the resources
  6. Clean up any temporary files
  7. Print the public key token from my output assembly
An example of one of those post-build scripts is this:

call "C:Program Files (x86)Microsoft Visual Studio 12.0Common7ToolsVsDevCmd.bat" copy "$(TargetPath)" "C:Program Files (x86)Microsoft Dynamics NAV80RoleTailored ClientAdd-insCRS" > NULmd "C:Temp" > NULset npres=$(ProjectDir)ResourceResource.zipif exist "%npres%" del "%npres%" > NUL"$(ProjectDir)Build Tools7z.exe" a -tzip -r "%npres%" "$(ProjectDir)Resource*.*" > NULcopy "%npres%" "C:Temp" /y > NULcopy "%npresproxy%" "C:Temp" /y > NULpowershell -ExecutionPolicy unrestricted -file "$(ProjectDir)Build ToolsImportResource.ps1" > NULdel "C:TempResource.zip" > NULrd "C:Temp" /Q > NULsn -T "$(TargetPath)"

Depending on your installation, it might not just work, maybe you’d need to fix some paths. Also, you must include this PowerShell script, as well as 7z.exe in your project. I typically have a folder called Build Tools where I put all the necessary dependencies for the build process.

And that’s all.

Now, this is not the best way, of course, to do this. A much better way would be to develop build tasks, and create a Visual Studio plugin that handles all this, but just call me too lazy to do that. This simple script gets the job done for me, and if it does the same for you, all the better.

Good luck, and let me know what you think of it. It’s okay to say “this sucks”

Read this post at its original location at http://vjeko.com/blog/deploy-your-re...-visual-studio, or visit the original blog at http://vjeko.com. 5e33c5f6cb90c441bd1f23d5b9eeca34The post Deploy your resource automatically from Visual Studio appeared first on Vjeko.com.

</img> </img>

Читать дальше
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 22:03.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.