vsix 模板中对多个运行时 .NET Core 的交互式窗口支持 [英] Interactive window support for multiple runtimes .NET Core in vsix template

查看:16
本文介绍了vsix 模板中对多个运行时 .NET Core 的交互式窗口支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为 VSIX 创建模板时,我们可以允许用户选择 .Net 框架版本做法是这样的:

In creating a template for VSIX we can allow the user to choose the .Net framework version This is how it is done:

<TargetFrameworkVersion>v$targetframeworkversion$</TargetFrameworkVersion>

现在,随着新版 Visual Studio (16.8) 的发布,这也允许用户选择 .NET Core 版本.但是这段代码似乎在 .NET Core 模板项目中不起作用,并且显示了不同的数字,而不是 netcoreapp3.1 或 net50-windows 值..net 核心也使用 而不是 那么正确的参数是什么?我测试了这些:

Now, with the release of the new version of Visual Studio (16.8), This allows the user to select the .NET Core version as well. But this code does not seem to work in the .NET Core template project and shows different numbers instead of netcoreapp3.1 or net50-windows values. also .net core use <TargetFramework> instead of <TargetFrameworkVersion> so What is the correct parameter? I tested these:

1.结果 = 4.5

<TargetFrameworkVersion>$targetframeworkversion$</TargetFrameworkVersion>

2.result = $targetframework$

2.result = $targetframework$

<TargetFramework>$targetframework$</TargetFramework>

3.result = 4.5

3.result = 4.5

<TargetFramework>$targetframeworkversion$</TargetFramework>

推荐答案

我认为到目前为止您无法为 Net Core 创建这样的 vsix 项目模板.

I think you cannot create a such vsix project template for Net Core so far.

我认为您已经创建了项目模板项目来实现您的要求.

I think you have created the project template project to realize your requirements.

并且您应该注意,此项目模板使用旧的 sdk 样式格式,而不是新的 sdk 格式(Net Core).而且,它传入和传出的始终是Net Framework的框架.

And you should note that this project template uses the old sdk style format rather than the new-sdk format(Net Core). Also, what it passes in and out is always the framework of Net Framework.

所以无论你如何在这个模板的基础上改变它的proj形式,它永远是net框架.可以看到这个界面,是我自己创建的自定义模板,我改成使用

So no matter how you change its proj form on the basis of this template, it will always be net framework. You can see this interface, it is a custom template created by me, I will change it to use

<Project Sdk="Microsoft.NET.Sdk">
....

<TargetFramework>$targetframeworkversion$</TargetFramework>

.....

</Project>

我还卸载了项目模板项目-->编辑 xxx.csproj 文件,更改为使用这些:

And I also unload the Project Template propject--> edit the xxx.csproj file ,change to use these:

 <Project Sdk="Microsoft.NET.Sdk">
    ....
    
    <TargetFramework>netcoreapp3.1</TargetFramework>
    
    .....
    
  </Project>

构建项目模板并将其放入C:\Users\xxx\Documents\Visual Studio 2019\Templates\ProjectTemplates.

Build the project template and put it into the C:\Users\xxx\Documents\Visual Studio 2019\Templates\ProjectTemplates.

重启VS,然后使用那个模板,你可以看到:

Restart VS and then use that tamplate, you can see this:

总是以net frameowrk为目标.并且证明修改后的框架是由项目模板项目本身的内部参数控制的,我们不能改变这个内部参数.

It always target with net frameowrk. And it proves that the modified framework is controlled by the internal parameters of the project template project itself, and we cannot change this internal parameter.

详细$targetframeworkversion$是项目模板本身的参数,因为项目模板是微软用net framework发布的,所以参数总是net framework,其他不可控的行为也会导致模板项目的损坏.所以我们不能得到 Net Core .

In detailed, $targetframeworkversion$ is the parameter from the project template itself and since the project template is released by Microsoft with net framework, so the parameter is always net framework and other uncontrollable behavior can also lead to template project's corruption. So we cannot get the Net Core with that.

建议

建议,您应该联系 Microsoft 团队 DC 论坛github 以新的 sdk 格式(Net核心格式).

As a suggestion, you should contact with the Microsoft's Team on DC Forum or github to release a new project template project with the new sdk format(Net Core format).

这篇关于vsix 模板中对多个运行时 .NET Core 的交互式窗口支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆