2017-05-23 6 views
5

を使用してWPFアプリケーションは、私がVS 2017の下に新しい形式に、古いcsproj形式を使用して定義され、WPFのプロジェクトの移行を試しています新しいcsproj形式

私は成功したビルドに道のほとんどを得ることができました私はHow-to migrate Wpf projects to the new VS2017 formatにある情報を使用しています。

しかし、私はこのエラーを過ぎて得ることでこだわっている:私はそのエントリポイントようcsprojファイルを設定するにはどうすればよい

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

    <PropertyGroup> 
    <LanguageTargets>$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets</LanguageTargets> 
    <OutputType>winexe</OutputType> 
    <TargetFramework>net47</TargetFramework> 
    <ApplicationIcon /> 
    <OutputTypeEx>winexe</OutputTypeEx> 
    <StartupObject /> 
    </PropertyGroup> 

    <ItemGroup> 
    <EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" /> 
    <Compile Update="Properties\Resources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Resources.resx" /> 
    <Compile Update="Settings.Designer.cs" AutoGen="True" DependentUpon="Settings.settings" /> 
    <None Update="Settings.settings" LastGenOutput="Settings.Designer.cs" Generator="SettingsSingleFileGenerator" /> 

    <Page Include="**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" /> 
    <Compile Update="**\*.xaml.cs" SubType="Designer" DependentUpon="%(Filename)" /> 

    <Resource Include="assets\*.*" /> 
    </ItemGroup> 

    <ItemGroup> 
    <PackageReference Include="Autofac" Version="4.6.0" /> 
    <PackageReference Include="Autofac.Extras.CommonServiceLocator" Version="4.0.0" /> 
    <PackageReference Include="Extended.Wpf.Toolkit" Version="3.0.0" /> 
    <PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.0.8" /> 
    <PackageReference Include="MaterialDesignColors" Version="1.1.3" /> 
    <PackageReference Include="MaterialDesignThemes" Version="2.3.0.823" /> 
    <PackageReference Include="MvvmLightLibs" Version="5.3.0" /> 
    <PackageReference Include="Serilog" Version="2.4.0" /> 
    <PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" /> 
    </ItemGroup> 

    <ItemGroup> 
    <ProjectReference Include="..\..\WPFUtilities\J4JUI\J4JUI.csproj" /> 
    </ItemGroup> 

    <ItemGroup> 
    <Reference Include="System.ComponentModel.DataAnnotations" /> 
    </ItemGroup> 

    <Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" /> 
</Project> 

を次のように

error CS5001: Program does not contain a static 'Main' method suitable for an entry point

私の新しいスタイルのcsprojファイルがあります建てる?私はコンパイルするプロジェクトを取得することができたApplicationDefinitionに関するヒントをもとに

更新

。 BuildActionにApplicationDefinitionを設定できませんでした。これは選択肢の1つではありませんでしたが、手動でcsprojファイルを編集して追加する必要がありました。

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

    <PropertyGroup> 
    <LanguageTargets>$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets</LanguageTargets> 
    <OutputType>winexe</OutputType> 
    <TargetFramework>net47</TargetFramework> 
    <ApplicationIcon /> 
    <OutputTypeEx>winexe</OutputTypeEx> 
    <StartupObject /> 
    </PropertyGroup> 

    <ItemGroup> 
    <EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" /> 
    <Compile Update="Properties\Resources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Resources.resx" /> 
    <Compile Update="Settings.Designer.cs" AutoGen="True" DependentUpon="Settings.settings" /> 
    <None Update="Settings.settings" LastGenOutput="Settings.Designer.cs" Generator="SettingsSingleFileGenerator" /> 

    <Page Include="**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" Exclude="App.xaml" /> 
    <Compile Update="**\*.xaml.cs" SubType="Designer" DependentUpon="%(Filename)" /> 

    <Resource Include="assets\*.*" /> 

    <ApplicationDefinition Include="App.xaml"> 
     <Generator>MsBuild:Compile</Generator> 
     <SubType>Designer</SubType> 
    </ApplicationDefinition> 

    </ItemGroup> 

    <ItemGroup> 
    <PackageReference Include="Autofac" Version="4.6.0" /> 
    <PackageReference Include="Autofac.Extras.CommonServiceLocator" Version="4.0.0" /> 
    <PackageReference Include="Extended.Wpf.Toolkit" Version="3.0.0" /> 
    <PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.0.8" /> 
    <PackageReference Include="MaterialDesignColors" Version="1.1.3" /> 
    <PackageReference Include="MaterialDesignThemes" Version="2.3.0.823" /> 
    <PackageReference Include="MvvmLightLibs" Version="5.3.0" /> 
    <PackageReference Include="Serilog" Version="2.4.0" /> 
    <PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" /> 
    </ItemGroup> 

    <ItemGroup> 
    <ProjectReference Include="..\..\WPFUtilities\J4JUI\J4JUI.csproj" /> 
    </ItemGroup> 

    <ItemGroup> 
    <Reference Include="System.ComponentModel.DataAnnotations" /> 
    </ItemGroup> 

    <Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" /> 
</Project> 

ディレクティブの除外フィルタにも注意してください。 MSBuildがApp.xaml.csを2回コンパイルしようとしないようにする必要があります。

+0

:結果は、あなたのcsprojファイルに以下の項目です。 – damageboy

答えて

4

ApplicationDefinitionにBuild ActionをApp.xamlに設定する必要があります。あなたは聖人です

<ApplicationDefinition Include="App.xaml"> 
    <Generator>MSBuild:Compile</Generator> 
    <SubType>Designer</SubType> 
</ApplicationDefinition> 
+0

Thanx! BuildActionがApplicationDefinitionのオプションを提供しなかったので、私はcsprojファイルにそのxmlをどこに置くべきかを理解しなければならなかった。 –

+0

あなたも聖者です! – damageboy

関連する問題