.net core ';dotnet构建&x27;将dotnetcore项目迁移到1.0.4后出错
我一直在尝试在迁移的.net核心项目上运行dotnet build命令(从1.0.0-preview2-003131到1.0.4)。我遵循了迁移上述项目的步骤,并使用Visual Studio 2017构建了解决方案。但是,使用dotnet CLI命令“dotnet build”会出现以下错误: C:\程序 Files\dotnet\sdk\1.0.4\Microsoft.Common.CurrentVersion.targets(2867,5): 错误MSB4216:无法运行“GenerateResource”任务,因为 MSBuild无法创建或连接到运行时为“CLR4”的任务主机 和体系结构“x86”。请确保(1)请求的运行时 和/或架构在机器上可用,以及(2) 必需的可执行文件“C:\Program Files\dotnet\sdk\1.0.4\MSBuild.exe” 存在并可以运行 我之前已经迁移了一些其他服务,在整理了一些包依赖关系之后,CLI命令工作得很好。我检查了错误中提到的sdk位置,但找不到MSBuild.exe(但找到了MSBuild.dll和MSBuild.deps文件)。我需要CLI命令来为我的CI/CD设置工作。非常感谢您对破译和修复此错误的任何帮助 系统详细信息:.net core ';dotnet构建&x27;将dotnetcore项目迁移到1.0.4后出错,.net-core,visual-studio-2017,msbuild-4.0,dotnet-cli,.net Core,Visual Studio 2017,Msbuild 4.0,Dotnet Cli,我一直在尝试在迁移的.net核心项目上运行dotnet build命令(从1.0.0-preview2-003131到1.0.4)。我遵循了迁移上述项目的步骤,并使用Visual Studio 2017构建了解决方案。但是,使用dotnet CLI命令“dotnet build”会出现以下错误: C:\程序 Files\dotnet\sdk\1.0.4\Microsoft.Common.CurrentVersion.targets(2867,5): 错误MSB4216:无法运行“Generate
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C092FA80-6783-4282-A3B0-C589FB3027F8}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Siemens.PLM.Teamcenter.DatasetService.PLDrive</RootNamespace>
<AssemblyName>DatasetService.PLDrive</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MimeTypesMap, Version=1.0.1.0, Culture=neutral, PublicKeyToken=1b320cc08ad5aa89, processorArchitecture=MSIL">
<HintPath>..\..\packages\MimeTypesMap.1.0.1\lib\net451\MimeTypesMap.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="AppToolbar.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ConsolePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ListPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="AppToolbar.xaml.cs">
<DependentUpon>AppToolbar.xaml</DependentUpon>
</Compile>
<Compile Include="DatasetList.cs" />
<Compile Include="ListPage.xaml.cs">
<DependentUpon>ListPage.xaml</DependentUpon>
</Compile>
<Compile Include="MessageTypeEnum.cs" />
<Compile Include="ConsolePage.xaml.cs">
<DependentUpon>ConsolePage.xaml</DependentUpon>
</Compile>
<Compile Include="DatasetService.cs" />
<Compile Include="FileIndex.cs" />
<Compile Include="FileWatcher.cs" />
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="MessageListener.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
调试
任意CPU
{C092FA80-6783-4282-A3B0-C589FB3027F8}
温克斯
性质
西门子.PLM.Teamcenter.DatasetService.PLDrive
DatasetService.PLDrive
v4.5.2
512
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
4.
真的
发表\
真的
圆盘
假的
前景
7.
天
假的
假的
真的
0
1.0.0.%2a
假的
假的
真的
任意CPU
真的
满的
假的
bin\Debug\
调试;痕迹
促使
4.
任意CPU
pdbonly
真的
bin\Release\
痕迹
促使
4.
..\..\packages\MimeTypesMap.1.0.1\lib\net451\MimeTypesMap.dll
真的
..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll
真的
4
MSBuild:编译
设计师
设计师
MSBuild:编译
设计师
MSBuild:编译
设计师
MSBuild:编译
设计师
MSBuild:编译
MSBuild:编译
设计师
App.xaml
代码
AppToolbar.xaml
ListPage.xaml
ConsolePage.xaml
MainPage.xaml
MainWindow.xaml
代码
代码
真的
真的
Resources.resx
真的
设置。设置
真的
ResXFileCodeGenerator
Resources.Designer.cs
设置单个文件生成器
Settings.Designer.cs
假的
Microsoft.NET Framework 4.5.2%28x86和x64%29
真的
假的
.NET Framework 3.5 SP1
假的
原始解决方案编译和构建时没有任何问题。我对此有点陌生,但对于一个有针对两个不同版本的dotnet的项目的解决方案是如何编译的(以及为什么在迁移时构建过程失败),我有点困惑。我应该单独运行migrate命令吗?(仅在.xproj项目上)包含在.NET Core CLI中的MSBuild的.NET Core版本能够在windows计算机上构建经典项目,只要它们的目标为.NET Framework>=4.0,安装了引用程序集并且未使用特殊目标/任务 在本例中,您尝试使用与主机MSBuild实例不同的体系结构编译资源。这在即将推出的2.0工具中开始的基于SDK的项目中得到了解决,但经典项目依赖MSBuild使用不同的CLR启动额外的进程,这在.NET Core上不受支持 解决此问题的简单方法是不使用
dotnet
命令来还原/生成解决方案,而是使用与visual studio一起安装的msbuild.exe,使用开发人员命令提示符,使用它们的msbuild
等效命令来还原/生成解决方案。(例如=>msbuild/t:Restore
,msbuild
,msbuild/t:Publish/p:Configuration=Release
等)
另一个解决方法是编辑有问题的csproj文件,将其添加到“旧”项目中的
:
当前架构
当前运行时
关于这个问题有一个很好的解释。项目的目标是什么框架?可以添加csproj/original project.json文件吗?可以。请注意,“core”旁边有一个打字错误(缺少一个结尾的双引号)。我见过这与体系结构无关,在
v4.7.1
framework WinForms应用程序中,通过向.csproj中对应于构建配置的每个属性组添加false
,解决了这个问题,例如Debug | AnyCPU
。(dotnet\sdk\2.1.201
)。
<PropertyGroup Condition="'$(MSBuildRuntimeType)' == 'Core'">
<GenerateResourceMSBuildArchitecture>CurrentArchitecture</GenerateResourceMSBuildArchitecture>
<GenerateResourceMSBuildRuntime>CurrentRuntime</GenerateResourceMSBuildRuntime>
</PropertyGroup>