简体   繁体   English

为什么我不能在 Visual Studio 2015 中创建共享项目?

[英]Why can't I create Shared Project in Visual Studio 2015?

I downloaded visual studio community 2015. I tried to create a Shared Project and am getting an error:我下载了 Visual Studio 社区 2015。我尝试创建一个共享项目,但出现错误:

在此处输入图片说明

Content from Microsoft.Windows.UI.Xaml.CSharp.targets来自 Microsoft.Windows.UI.Xaml.CSharp.targets 的内容

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup Condition="'$(TargetPlatformVersion)'==''">
        <TargetPlatformVersion>8.0</TargetPlatformVersion>
    </PropertyGroup>

    <PropertyGroup Condition="'$(TargetPlatformIdentifier)' == 'UAP'">
        <RedirectionTarget>8.2</RedirectionTarget>
    </PropertyGroup>

    <PropertyGroup Condition="'$(RedirectionTarget)' == ''">
        <RedirectionTarget>$(TargetPlatformVersion)</RedirectionTarget>
    </PropertyGroup>

    <!-- Direct 8.0 projects to 8.1 targets to enable retargeting  -->
    <PropertyGroup Condition="'$(RedirectionTarget)' == '8.0'">
        <RedirectionTarget>8.1</RedirectionTarget>
    </PropertyGroup>

    <Import Project="$(RedirectionTarget)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
</Project>

I do not have folder with name 8.1我没有名称为 8.1 的文件夹

One workaround is to make the following edits:一种解决方法是进行以下编辑:

Open the file %ProgramFiles(x86)%\\MSBuild\\Microsoft\\VisualStudio\\v14.0\\CodeSharing\\Microsoft.CodeSharing.CSharp.targets (for Visual Basic the file is Microsoft.CodeSharing.VisualBasic.targets ) and look for the following entries around line 8 -打开文件%ProgramFiles(x86)%\\MSBuild\\Microsoft\\VisualStudio\\v14.0\\CodeSharing\\Microsoft.CodeSharing.CSharp.targets (对于 Visual Basic,文件是Microsoft.CodeSharing.VisualBasic.targets )并查找以下条目8号线附近——

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets')"/>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" Condition="!Exists('$(MSBuildExtensionsPath32)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets')" />    

Change these lines to the following -将这些行更改为以下内容 -

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" Condition="false"/>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" Condition="true" />

Basically, undo the conditional import of the Xaml based shared projects.基本上,撤消基于Xaml的共享项目的条件导入。

This is (believe it or not) the advice I received from MS for this issue.这是(信不信由你)我从 MS 收到的关于这个问题的建议。 I think it's related to an unclean upgrade of the RC (or earlier) versions to RTM and the selection of different options during install.我认为这与将 RC(或更早)版本不干净地升级到 RTM 以及在安装过程中选择不同的选项有关。


(Insert usual caveats about editing files that don't "belong" to you, take backups, and if you're not confident to make such edits, don't) (插入关于编辑不“属于”您的文件的常见警告,进行备份,如果您没有信心进行此类编辑,请不要)

Try to copy 8.0 and 8.1 directories from C:\\Program Files (x86)\\MSBuild\\Microsoft\\WindowsXaml\\v12.0 to C:\\Program Files (x86)\\MSBuild\\Microsoft\\WindowsXaml\\v14.0 (notice version number at the end).尝试将 8.0 和 8.1 目录从 C:\\Program Files (x86)\\MSBuild\\Microsoft\\WindowsXaml\\v12.0 复制到 C:\\Program Files (x86)\\MSBuild\\Microsoft\\WindowsXaml\\v14.0(注意版本号在结束)。

It seems that those are missing in 2015 installation on windows 7.在 Windows 7 上的 2015 安装中似乎缺少这些。

You'll need to restart Visual Studio after that.之后您需要重新启动 Visual Studio。

To fix this issue install the Windows 8/8.1 Project templates.要解决此问题,请安装 Windows 8/8.1 项目模板。

All I did was:我所做的只是:

  1. Open VS 2015打开 VS 2015
  2. Click File->New->Project点击文件->新建->项目
  3. Choose the only Project template under Windows 8选择 Windows 8 下唯一的 Project 模板

This will launch Visual Studio setup where you can install the templates that are missing.这将启动 Visual Studio 安装程序,您可以在其中安装缺少的模板。

Then you can create your Project.然后你可以创建你的项目。

This is not a hard problem.这不是一个困难的问题。 Mr. Kriper (the original asker of the question) likely installed using the "Default Install" for his version of Visual Studio 2015. Mr. Kondrasovas in Answer 2 points to needing to install more components. Kriper 先生(问题的原始提问者)可能使用他的 Visual Studio 2015 版本的“默认安装”进行安装。Kondrasovas 先生在答案 2 中指出需要安装更多组件。 His approach resulted in a Visual Studio displaying a setup utility error which is no fault of Mr. Kondrasovas.他的方法导致 Visual Studio 显示设置实用程序错误,这不是 Kondrasovas 先生的错。 Mr. Kondrasovas answer is likely correct if you do not encounter an error (I have no way to verify the answer).如果您没有遇到错误,Kondrasovas 先生的回答可能是正确的(我无法验证答案)。

The solution is to go to Control Panel |解决办法是进入控制面板| Programs |节目 | Uninstall a program.卸载程序。 Select Visual Studio 2015 and "Modify" the installed instance of Visual Studio 2015:选择 Visual Studio 2015 并“修改”已安装的 Visual Studio 2015 实例:

[sorry I cannot show the image b/c I do not have a 10 for a reputation and StackOverflow.com is blocking me] [抱歉,我无法显示图像 b/c 我没有 10 的声誉,而 StackOverflow.com 阻止了我]

The previous (imaginary) screenshot is from the default install of Visual Studio 2015 Professional.上一个(假想的)屏幕截图来自 Visual Studio 2015 Professional 的默认安装。 You can mess around and figure out the exact feature to install or if you have the disk space, simply click on "Select All" and then "Next".您可以四处乱搞并找出要安装的确切功能,或者如果您有磁盘空间,只需单击“全选”,然后单击“下一步”。 Hint: the "Next" button is not enabled until a change is made to the selected components of Visual Studio 2015.提示:在对 Visual Studio 2015 的选定组件进行更改之前,不会启用“下一步”按钮。

If you want to see the missing image a complete write up, I wrote a blog post on the issue: http://www.softwarepronto.com/2015/08/visual-studio-2015-error-adding-shared.html如果您想查看完整的缺失图像,我写了一篇关于该问题的博客文章: http : //www.softwarepronto.com/2015/08/visual-studio-2015-error-adding-shared.html

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

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