Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
485 views
in Technique[技术] by (71.8m points)

c# - 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:

enter image description here

Content from 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

One workaround is to make the following edits:

Open the file %ProgramFiles(x86)%MSBuildMicrosoftVisualStudiov14.0CodeSharingMicrosoft.CodeSharing.CSharp.targets (for Visual Basic the file is Microsoft.CodeSharing.VisualBasic.targets) and look for the following entries around line 8 -

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

Change these lines to the following -

<Import Project="$(MSBuildExtensionsPath32)MicrosoftWindowsXamlv$(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.

This is (believe it or not) the advice I received from MS for this issue. 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.


(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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...