The Visual Studio for Mac compile error: Your project file doesn't list 'win' as a "RuntimeIdentifier"
The Visual Studio for Mac compile error: Your project file doesn't list 'win' as a "RuntimeIdentifier"
我在编译 C# 代码时遇到了一些小问题。
我相信这个错误发生在我想将我的项目发布到 NuGet 并且我更改了我的项目的 .csproj
文件时,但令人难以置信的是我的项目在 github 上并且我恢复了工作版本但出现了同样的错误.
完整错误代码:
/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/xbuild/Microsoft/NuGet/Microsoft.NuGet.targets(5,5): Error: Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
我的实际项目的.csproj
文件内容:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D1B1F4F8-C9CF-4DC4-966D-DD7FF4683A1C}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>AirlyNet</RootNamespace>
<AssemblyName>AirlyNet</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<PackOnBuild>true</PackOnBuild>
<PackageId>AirlyNet</PackageId>
<PackageVersion>0.1</PackageVersion>
<Authors>Mondonno</Authors>
<NeutralLanguage>en-US</NeutralLanguage>
<Owners>Mondonno</Owners>
<PackageProjectUrl>https://github.com/Mondonno</PackageProjectUrl>
<PackageReleaseNotes>The pre-release of our wrapper</PackageReleaseNotes>
<PackageTags>airly airly.net c# csharp</PackageTags>
<Title>Airly.Net</Title>
<Description>Wrapper for the Airly API written 100% in C# </Description>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\AirlyNet.xml</DocumentationFile>
<ConsolePause>false</ConsolePause>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Formatting" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="contents\common\AirlyConfiguration.cs" />
<Compile Include="contents\common\AirlyModels.cs" />
<Compile Include="contents\common\cache\Caches.cs" />
<Compile Include="contents\common\handling\Errors.cs" />
<Compile Include="contents\common\handling\Handlings.cs" />
<Compile Include="contents\common\handling\RateLimitInfo.cs" />
<Compile Include="contents\interactions\InteractionBase.cs" />
<Compile Include="contents\interactions\structures\Installations.cs" />
<Compile Include="contents\interactions\structures\Measurments.cs" />
<Compile Include="contents\interactions\structures\Meta.cs" />
<Compile Include="contents\rest\api\RequestModule.cs" />
<Compile Include="contents\rest\api\RequestProviders.cs" />
<Compile Include="contents\rest\queue\RequestQueueHandler.cs" />
<Compile Include="contents\rest\queue\RequestQueueManager.cs" />
<Compile Include="contents\rest\queue\RequestQueuer.cs" />
<Compile Include="contents\rest\RestApiClient.cs" />
<Compile Include="contents\rest\RestManager.cs" />
<Compile Include="contents\rest\RestTypings.cs" />
<Compile Include="contents\utils\ArrayUtil.cs" />
<Compile Include="contents\utils\GeoUtil.cs" />
<Compile Include="contents\utils\JsonParser.cs" />
<Compile Include="contents\utils\Utils.cs" />
<Compile Include="contents\Airly.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="contents\" />
<Folder Include="contents\common\" />
<Folder Include="contents\interactions\" />
<Folder Include="contents\rest\" />
<Folder Include="contents\utils\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
我尝试添加 RuntimeIdentifier
和 RuntimeIdentifiers
但遇到同样的错误,我也尝试更改它并重新启动 VS 但还是一样。
谢谢!
为了解决这个问题,我从我的解决方案文件夹中删除了 obj
目录
里面有东西坏了,当 VS 重新生成它时,问题就消失了
感谢 @Matt Ward 在有问题的评论中提出此建议。
我在编译 C# 代码时遇到了一些小问题。
我相信这个错误发生在我想将我的项目发布到 NuGet 并且我更改了我的项目的 .csproj
文件时,但令人难以置信的是我的项目在 github 上并且我恢复了工作版本但出现了同样的错误.
完整错误代码:
/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/xbuild/Microsoft/NuGet/Microsoft.NuGet.targets(5,5): Error: Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
我的实际项目的.csproj
文件内容:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D1B1F4F8-C9CF-4DC4-966D-DD7FF4683A1C}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>AirlyNet</RootNamespace>
<AssemblyName>AirlyNet</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<PackOnBuild>true</PackOnBuild>
<PackageId>AirlyNet</PackageId>
<PackageVersion>0.1</PackageVersion>
<Authors>Mondonno</Authors>
<NeutralLanguage>en-US</NeutralLanguage>
<Owners>Mondonno</Owners>
<PackageProjectUrl>https://github.com/Mondonno</PackageProjectUrl>
<PackageReleaseNotes>The pre-release of our wrapper</PackageReleaseNotes>
<PackageTags>airly airly.net c# csharp</PackageTags>
<Title>Airly.Net</Title>
<Description>Wrapper for the Airly API written 100% in C# </Description>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\AirlyNet.xml</DocumentationFile>
<ConsolePause>false</ConsolePause>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Formatting" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="contents\common\AirlyConfiguration.cs" />
<Compile Include="contents\common\AirlyModels.cs" />
<Compile Include="contents\common\cache\Caches.cs" />
<Compile Include="contents\common\handling\Errors.cs" />
<Compile Include="contents\common\handling\Handlings.cs" />
<Compile Include="contents\common\handling\RateLimitInfo.cs" />
<Compile Include="contents\interactions\InteractionBase.cs" />
<Compile Include="contents\interactions\structures\Installations.cs" />
<Compile Include="contents\interactions\structures\Measurments.cs" />
<Compile Include="contents\interactions\structures\Meta.cs" />
<Compile Include="contents\rest\api\RequestModule.cs" />
<Compile Include="contents\rest\api\RequestProviders.cs" />
<Compile Include="contents\rest\queue\RequestQueueHandler.cs" />
<Compile Include="contents\rest\queue\RequestQueueManager.cs" />
<Compile Include="contents\rest\queue\RequestQueuer.cs" />
<Compile Include="contents\rest\RestApiClient.cs" />
<Compile Include="contents\rest\RestManager.cs" />
<Compile Include="contents\rest\RestTypings.cs" />
<Compile Include="contents\utils\ArrayUtil.cs" />
<Compile Include="contents\utils\GeoUtil.cs" />
<Compile Include="contents\utils\JsonParser.cs" />
<Compile Include="contents\utils\Utils.cs" />
<Compile Include="contents\Airly.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="contents\" />
<Folder Include="contents\common\" />
<Folder Include="contents\interactions\" />
<Folder Include="contents\rest\" />
<Folder Include="contents\utils\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
我尝试添加 RuntimeIdentifier
和 RuntimeIdentifiers
但遇到同样的错误,我也尝试更改它并重新启动 VS 但还是一样。
谢谢!
为了解决这个问题,我从我的解决方案文件夹中删除了 obj
目录
里面有东西坏了,当 VS 重新生成它时,问题就消失了
感谢 @Matt Ward 在有问题的评论中提出此建议。