csproj

How to upgrade csproj files with VS2017

ε祈祈猫儿з 提交于 2019-11-28 19:11:13
VS2017 has so far correctly converted several project.json / .xproj based projects to the new .csproj format. I would also like to use the new .csproj format with older .csproj projects that previously targeted only .NET Framework (i.e. they didn't work with dnx/dotnet CLI). It seems that even if a project would still only target .NET Framework, the benefits of <PackageReference> and an easily editable .csproj file seem worth the (hopefully not too great) trouble. Is this possible to do with Visual Studio 2017 directly? If not, what manual steps would be required? Mark I'm editing my answer to

Relationship between the dotnet cli and the new vs2017 msbuild

我是研究僧i 提交于 2019-11-28 16:10:24
With the move from project.json to the new csproj format introduced with VS2017, I'm struggling to understand the difference between the dotnet cli and the new msbuild and when to use one over the other. 1) To build a new csproj netstandard library from the command line, should I be calling the dotnet cli (for example dotnet restore dotnet build ) or use msbuild (for example msbuild ExampleNetstandard.sln ). 2) Also, my understanding is that there are two versions of msbuild , one built on the full framework and another targeting dotnet core . Is this correct? Should I always use the dotnet

Understanding a csproj assembly reference

为君一笑 提交于 2019-11-28 16:03:27
I am using VS2010 and I tried to add a few assemblies from local hard disk to my C# project through file reference. Peeking into the csproj file, I found sometimes the file reference appears as <Reference Include="name"> However sometimes it appears as <Reference Include="name, Version=xxx, Culture=neutral, processorArchitecture=MSIL"> What could cause the difference? Inspired by k3b's answer, I did another test. I created a new class library project. Add a file reference. The initial value of Specific Version in Properties pane is False . The csproj file look like <Reference Include="Name">

What is “Service Include” in a csproj file for?

二次信任 提交于 2019-11-28 14:46:28
问题 In a C# solution, I added a existing project. After that, Visual Studio has added the following entry in other .csproj files: <ItemGroup> <Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" /> </ItemGroup> What's this for? Can I delete it? 回答1: I had a similar case, where this was added: <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> </ItemGroup> This inclusion turns out to be generated on purpose by VS2013 if you create an NUnit test project, but forget to tag

Possible to remove and add a reference to csproj programmatically via a batch file?

你。 提交于 2019-11-28 09:31:58
问题 I am writing a short batch file to prepare a control library DLL with Examples project for deployment via sip file and have the following question. Given a csproj file at known location and a DLL at known location, is it possible to programmatically update the csproj from the batch file (via third party command line exe, or other scripting) to add the new DLL? My folder structure is /Build /SDK /WPF /4.0 : ControlLibrary.dll sits here /Examples /WPF /4.0 : Examples.csproj sits here Assuming

Reading the list of References from csproj files

旧巷老猫 提交于 2019-11-28 07:20:08
Does anyone know of a way to programmatically read the list of References in a VS2008 csproj file? MSBuild does not appear to support this functionality. I'm trying to read the nodes by loading the csproj file into an XmlDocument but, the XPath search does not return any nodes. I'm using the following code: System.Xml.XmlDocument projDefinition = new System.Xml.XmlDocument(); projDefinition.Load(fullProjectPath); System.Xml.XPath.XPathNavigator navigator = projDefinition.CreateNavigator(); System.Xml.XPath.XPathNodeIterator iterator = navigator.Select(@"/Project/ItemGroup"); while (iterator

BuildingInsideVisualStudio Property Value Not Working With File Reference and Project Reference Conditional

倾然丶 夕夏残阳落幕 提交于 2019-11-28 04:52:51
问题 I am trying to add a project and file reference to the same dll in the csproj with the BuildingInVsideisualStudio property. But when they are in the csproj together, only the file reference is picked up. If I remove the file reference, it picks up the csproj. I have tried swapping the order, but no luck. Any ideas why this doesn't work? Here is the basic idea: <ItemGroup Condition="'$(BuildingInsideVisualStudio)' == false"> <Reference Include="MyNamespace.Mine"> <HintPath>..\$(OutDir)

MS-Build BeforeBuild not firing

我是研究僧i 提交于 2019-11-27 23:30:21
问题 I'm customising a .csproj project to run some custom tasks before the main build. However, I can't get the tasks to execute at all. I uncommented the <Target Name="BeforeBuild" /> element in the .csproj file and added a simple Message task, but when I build, the message doesn't appear in my output, so it seems the task isn't running. So this fragment does not output the message; Listing 1: No Message Appears <Target Name="BeforeBuild"> <Message Text="About to build ORM layer" Importance=

Build errors when multi-targeting in csproj file

谁说胖子不能爱 提交于 2019-11-27 23:05:21
问题 I'm trying to build a class library that multi-targets both .NET 4.5.1 and .NET Standard 1.3. According to the documentation, I should be able to do this: <PropertyGroup> <TargetFrameworks>net451;netstandard1.3</TargetFrameworks> </PropertyGroup> However, when I try to build, I get these odd errors: Cannot infer TargetFrameworkIdentifier and/or TargetFrameworkVersion from TargetFramework='net451'. They must be specified explicitly. MSB3645 .NET Framework v3.5 Service Pack 1 was not found. In

XPath and *.csproj

假装没事ソ 提交于 2019-11-27 23:00:52
I am for sure missing some important detail here. I just cannot make .NET's XPath work with Visual Studio project files. Let's load an xml document: var doc = new XmlDocument(); doc.Load("blah/blah.csproj"); Now execute my query: var nodes = doc.SelectNodes("//ItemGroup"); Console.WriteLine(nodes.Count); // whoops, zero Of course, there are nodes named ItemGroup in the file. Moreover, this query works: var nodes = doc.SelectNodes("//*/@Include"); Console.WriteLine(nodes.Count); // found some With other documents, XPath works just fine. I am absolutely puzzled about that. Could anyone explain