I am trying to build AnkhSVN based on the branch by Simonp22.
The solution includes the MSBuild target QQn.TurtleTasks.targets which contains two tasks:
QQn.TurtleTasks.CachedDownloadAndExtract
QQn.TurtleTasks.ApplyXslTransform
The targets file is imported into four projects in the solution.
The DLL QQn.TurtleTasks.dll is included in the repository (as a binary file). However, it targets .NET Framework 3.5, which I previously did not have installed on my computer.
I would like to get rid of the reference to Framework 3.5, so if possible I would like to replace or remove this reference.
It is not obvious to me, what these tasks are doing and what role they play in the build process.
Can anybody explain
What these tasks are doing?
What is QQn.TurtleTasks? Is it a project which still exists?
Is there a way to replace it?
This is the targets file:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="../tools/Ankh-Common.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{874C0358-E7DD-42DA-BF07-58198B41FD25}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>TestUtils</RootNamespace>
<AssemblyName>TestUtils</AssemblyName>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<SccProjectName>Svn</SccProjectName>
<SccLocalPath>Svn</SccLocalPath>
<SccAuxPath>Svn</SccAuxPath>
<SccProvider>SubversionScc</SccProvider>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>5</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>5</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\tools\turtletasks\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
<Reference Include="System.XML">
<Name>System.XML</Name>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ProcessReader.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Zip.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
Sorry, this is not directly a programming question, but it is a concrete problem related to programming and I think it can be answered. That is why I am asking on Stack Overflow.
Can I replace TurtleTasks in the AnkhSvn build. What is QQn.TurtleTasks? Is it a project which still exists?
I'm afraid no. That QQn.TurtleTasks is not a open-source project like AnkhSVN repos itself, I would think it's one old, Internal-use project, for this, you have to contact the authors of the AnkhSVN to get source project if it exists.
What these tasks are doing?
Take Ankh.Services.csproj as example, we can see something like:
<ItemGroup>
<DependencyDownload Include="SSvn-1.9005.3940.224.zip">
<Url>https://sharpsvn.open.collab.net/files/documents/180/18649/</Url>
<TargetDir>..\autolib</TargetDir>
<Version>1</Version>
<Visible>false</Visible>
</DependencyDownload>
<DependencyDownload Include="SGit-0.2401.1116.230.zip">
<Url>https://sharpsvn.open.collab.net/files/documents/180/12884/</Url>
<TargetDir>..\autolib</TargetDir>
<Version>1</Version>
<Visible>false</Visible>
</DependencyDownload>
</ItemGroup>
And the DependencyDownload Item is something that will be used by DownloadDependencies target here.
According to the content of these two files:
QQn.TurtleTasks.targets calls DownloadDependencies target=>CachedDownloadAndExtract task. And DependencyDownload item is the input of CachedDownloadAndExtract task(C# class that Implements Itask).
So for this task it will try to download xx.zip file from specific Url like https://sharpsvn.open.collab.net/files/documents/180/12884/ and cache them. But those real logic are hidden in the assembly QQn.TurtleTasks.dll.
So i think if you want to replace them, you have to contact the user to get source code of that QQn.TurtleTasks assembly or install .net framework 3.5 in your machine. Not a good suggestion, but after my check it's a quite old repos from VS2008(VS2005?), for such old project, .net 2.0 and 3.5 framework can help resolve many unknown issues.
Related
I have created a .NET Framework 4.8 C# Class Library project that uses x64 as the TargetFramework.
I have added the NuGet package Microsoft.SqlServer.Compact to the project.
When I build the project, only the System.Data.SqlServerCe.dll file, which sits flat in the \lib\net40 folder, is copied to the Output folder.
The files that are in the NativeBinaries\amd64\ directory of the NuGet package are not copied.
But I need them in the OutputPath\amd64 directory.
What settings do I need to make so that these files are also copied?
Edit
Here is the content of my csproj file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>{409AD54E-75FD-419F-B5D7-D2368105B4A8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NuGetSQLTestClassLibraryNetFramework</RootNamespace>
<AssemblyName>NuGetSQLTestClassLibraryNetFramework</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SqlServer.Compact">
<Version>4.0.8876.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
In my side, it works well and I have OutputPath\amd64 directory with the nuget package.
So please try the following steps to troubleshoot the issue:
1) clean nuget caches first or just delete all files under C:\Users\xxx\.nuget\packages
Also, delete the packages folder under <solution_folder>.
2) run update-package -reinstall under Tools-->Nuget Package Manager-->Package Manager Console
Update
Since you have used PackageReference nuget management format and you cannot get what you want in that format since the author did not consider the compatibility of PackageReference with the nuget package.
In my side, I used packages.config nuget management format and then get that.
To get what you want, you should add these additionally:
1) add this <GeneratePathProperty>true</GeneratePathProperty>under that nuget package reference node to generate msbuild property called PkgMicrosoft_SqlServer_Compact about the content path of the nupkg.
<ItemGroup>
<PackageReference Include="Microsoft.SqlServer.Compact">
<Version>4.0.8876.1</Version>
<GeneratePathProperty>true</GeneratePathProperty>
</PackageReference>
</ItemGroup>
2) right-click on the Proeject Properties-->Build Events-->post-build event command line--> add these:
if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
xcopy /s /y "$(PkgMicrosoft_SqlServer_Compact)\NativeBinaries\x86\*.*" "$(TargetDir)x86"
if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
xcopy /s /y "$(PkgMicrosoft_SqlServer_Compact)\NativeBinaries\amd64\*.*" "$(TargetDir)amd64"
After that, rebuild to get what you want.
I am trying to build my first uwp application. I am new to c# as well. I am using visual studio build tools 2019. I think I have done everything right but when I run msbuild, I get the following error:
"C:\Projects\C\UapHello\uaphello.csproj" (default target) (1) ->
(_ValidateAppxPackage target) ->
Package.appxmanifest(41,9): error APPX0703: Manifest references file 'Assets\Square150x150Logo.png' which is not part
of the payload. [C:\Projects\C\UapHello\uaphello.csproj]
Package.appxmanifest(42,9): error APPX0703: Manifest references file 'Assets\Square44x44Logo.png' which is not part o
f the payload. [C:\Projects\C\UapHello\uaphello.csproj]
Package.appxmanifest(27,6): error APPX0703: Manifest references file 'StoreLogo.png' which is not part of the payload
. [C:\Projects\C\UapHello\uaphello.csproj]
Package.appxmanifest(45,27): error APPX0703: Manifest references file 'Assets\SplashScreen.png' which is not part of
the payload. [C:\Projects\C\UapHello\uaphello.csproj]
I am pretty sure these files exist in said folder.
I am including my csproj and appmanifest:
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
xmlns:iot2="http://schemas.microsoft.com/appx/manifest/iot/windows10/2"
IgnorableNamespaces="uap mp uap5 iot2 desktop4">
<Identity
Name="IggyMakesThings"
Publisher="CN=IggyMakesThings, O=IggyMakesThings, L=Redmond, S=Washington, C=US"
Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="11a54d62-0d60-4e17-820d-1fa537715b3a" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.17763.0" />
</Dependencies>
<Properties>
<DisplayName>uaphello</DisplayName>
<PublisherDisplayName>IggyMakesThings</PublisherDisplayName>
<Logo>StoreLogo.png</Logo>
</Properties>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="uaphello.exe"
EntryPoint="UAPHello.App">
<uap:VisualElements
DisplayName="UAPSample"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="UAP C# Sample"
BackgroundColor="#000000">
<uap:SplashScreen Image="Assets\SplashScreen.png" />
<uap:DefaultTile>
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo" />
</uap:ShowNameOnTiles>
</uap:DefaultTile>
</uap:VisualElements>
</Application>
</Applications>
</Package>
And csproj:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" 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)' == '' ">Win32</Platform>
<ProjectGuid>{$guid1$}</ProjectGuid>
<OutputType>AppContainerExe</OutputType>
<RootNamespace>uaphello</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.17763.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
</PropertyGroup>
<PropertyGroup>
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'">
<PlatformTarget>x86</PlatformTarget>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.8" />
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
</Project>
Please help
I think something missing in your .csproj file caused this issue.
Steps to reproduce same issue:
1.Create a new Blank App(Universal Windows)
2.In VS, for those .png resources:Exclude from the project
3.Copy the solution to build server where only has build tools
4.Restore the nuget packages and build the project with command like:
msbuild path/xxx.csproj(or xxx.sln) /p:Platform=X64 /p:AppxBundle=Always
5.Get the error below:
You can follow my simple steps to locate the cause of the issue.
In my opinion:
You might do some similar operation like mine. Maybe Exclude from Project, maybe delete the ItemGroup content in xx.csproj file, or what.
The result is deleting the ItemGroup for those .png files in xx.csproj. If you create a new Blank App(UWP), and check its content of .csproj file you would see:
<ItemGroup>
<Content Include="Properties\Default.rd.xml" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Assets\StoreLogo.png" />
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>
But these content is missing in your .csproj file.
These four files which are used in your appmanifest are indeed in your asserts folder.
But without the content ref in .csproj file, the build process can't find them properly.Square150x150Logo.png,Square44x44Logo.png,StoreLogo.png,SplashScreen.png
As a workaround:
So you can edit your xx.csproj file, and add the ItemGroup into it.
But I'm not certainly sure it will work. Since after my checking your .csproj file. Maybe the .png files are not the only things you excluded or removed!!
I'm not sure how many changes you've made to the project, so if above not helps, just create a new project and copy your core code into the new project.
I'm attempting to create a nupkg with Visual Studio using the built in nuget package building and include the build directory from my project in the nupkg. It seems like it should be a fairly simple task but I can't get it to work. From my googling adding either of these to my csproj file should work, but both create an empty 'build' directory in the nupkg:
<ItemGroup>
<None Include="build\**">
<Pack>true</Pack>
<PackagePath>build\</PackagePath>
<IncludeInPackage>true</IncludeInPackage>
</None>
</ItemGroup>
Using nuget pack to create the package with the following in my nuspec does work:
<files>
<!-- Include everything in \build -->
<file src="build\**" target="build" />
</files>
Include build directory in nuget package using visual studio pack
According to the document Including content in a package, you should use the properties <Pack>true</Pack> and <PackagePath>build\</PackagePath>:
If you want to copy all your content to only a specific root folder(s) (instead of content and contentFiles both), you can use the MSBuild property ContentTargetFolders, which defaults to "content;contentFiles" but can be set to any other folder names.
PackagePath can be a semicolon-delimited set of target paths.
Specifying an empty package path would add the file to the root of the
package.
So, you can change your ItemGroup like following:
<ItemGroup>
<None Include="build\**" Pack="True" PackagePath="build\" />
</ItemGroup>
Update:
I believe this is the same as what I added but in a different XML
structure and without the Pack attribute
The Pack attribute is the key point. It works fine with your XML structure and the Pack attribute. You should make sure you have the files in the build folder in your project folder:
Check my test demo below:
Update2:
Ah! You are using the .net framework project!! That the reason for this issue. This method is used for .net standard and .net core project by default and it not work for .net framework. To resolve this issue you have to use the .nupsec file, like you post in the question.
If you still want to include build directory in nuget package using visual studio pack, you need change your project type to SDK type:
Check this document for some more details.
Then you can use the method, which we talked about before.
Hope this helps.
The solution to this issue was to upgrade the project to SDK type (Xamarin binding projects by default use the old format but seem to work with the new type) and then use:
<ItemGroup>
<None Update="build\**">
<IncludeInPackage>true</IncludeInPackage>
</None>
</ItemGroup>
To include the build directory. The alternative is using nuget pack.
When converting the project make sure to leave in the Xamarin import:
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.ObjCBinding.CSharp.targets" />
Here's how my project file looks afterwards:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<PackageId></PackageId>
<PackageVersion>3.3.2</PackageVersion>
<ReleaseVersion>$(PackageVersion)</ReleaseVersion>
<AssemblyVersion>$(PackageVersion)</AssemblyVersion>
<Authors>Nick Brook</Authors>
<Description></Description>
<Copyright></Copyright>
<PackageProjectUrl></PackageProjectUrl>
<Summary></Summary>
<PackageTags></PackageTags>
<Title></Title>
<PackageReleaseNotes>Initial Release</PackageReleaseNotes>
<OutputType>Library</OutputType>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<OutputPath>bin\$(Configuration)</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<PackageOutputPath>packed</PackageOutputPath>
<PackOnBuild>true</PackOnBuild>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingCoreSource Include="Structs.cs" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Structs.cs" Condition=" '$(EnableDefaultCompileItems)' == 'true' " />
<Compile Remove="ApiDefinition.cs" Condition=" '$(EnableDefaultCompileItems)' == 'true' " />
</ItemGroup>
<ItemGroup>
<None Remove="packed\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Build.Download" Version="0.4.11" />
<PackageReference Include="NuGet.Build.Packaging" Version="0.2.2" />
</ItemGroup>
<ItemGroup>
<None Update="build\**">
<IncludeInPackage>true</IncludeInPackage>
</None>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.ObjCBinding.CSharp.targets" />
</Project>
Is there a way to restrict the nuget update command to only update .proj references that match a particular condition? (Or a clever workaround to get to the desired outcome)
Scenario
I have a project file that brings in different references depending on the ${Configuration}
type. So, for example, if the ${configuration} matches ProjRef it will set certain external references as ProjectReferences. If the ${configuration} matches the standard Release or Debug it will set certain external references as References.
This works great until nuget is added to the mix. If I run a nuget update via command line it will modify the .proj file outside of the ${configuration} conditionals and, therefore, override them if the added lines come after the ${configuration} conditionals.
Example
Before Running Nuget Update
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Reference Include="X">
<HintPath>path\1.2.2\X.dll</HintPath>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'ProjRef|AnyCPU' ">
<ProjectReference Include="X.vbproj">
<Name>X</Name>
</ProjectReference>
</ItemGroup>
After Running Nuget Update:
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'ProjRef|AnyCPU' ">
<ProjectReference Include="X.vbproj">
<Name>X</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="X">
<HintPath>path\1.2.3\X.dll</HintPath>
</ItemGroup>
Notice that the lines added by nuget update will override the configuration specific lines resulting in no project reference -- even if built using ProjRef configuration.
I have a visual studio solution with a large number of projects in it, some of which target .NET v2.0, and some of which target v3.5.
I know I can right click on each project in turn to see which version it targets, but this would take for ever.
Does anyone know a quicker way I can determine which projects target v2.0 and which target v3.5?
EDIT:
I was hoping to be able to use the TargetFrameworkVersion node to determine the version, but some of the project files don't have this node, e.g.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E11A268C-9F62-4970-9338-129C35AD2354}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BusinessEntities</RootNamespace>
<AssemblyName>Business Entities</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="SomeClass.cs" />
<Compile Include="SomeOtherClass.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\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>
...but if I right click on the project in VS, it says that the target version is .NET v2.0. Also just to be clear, I need to repeat this process for a number of solutions, so doing it the manual way is a really undesirable option.
Thanks
There is a link might be helpful.
You have to write your own code to parse project files to get the framework versions.
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
The other option is to use command line for the solution folder.
Use MS DOS command:
findstr "<TargetFrameworkVersion>" *.csproj
The result will be displayed on the screen.
UPDATE:
Because older progjects don't contain this line. We can use another command, which search files don't contain the line.
findstr /v "<TargetFrameworkVersion>" *.csproj