I have class library project for which I would like to create a nuget package.
So i first created a nuspec file by running the following in the project folder:
'nuget spec'
Then I added the following in my project file:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
<Message Text="### AfterBuild ###" Importance="high" />
<Exec Command="nuget pack MyProjectNameHere.csproj -Prop Platform=AnyCPU"></Exec>
</Target>
When I build the project from with VS, the package is not built and the message is not shown.
What am I missing?
Related
I have a .NETStandard 2.0 class library which is distributed via Nuget. It includes compiled native code libraries, specific to our target platforms. The .csproj looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>CoolProject</PackageId>
<Version>0.8.1</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AnotherCoolProject" Version="0.3.2" />
<PackageReference Include="YetAnotherCoolProject" Version="7.4.2" />
</ItemGroup>
<ItemGroup>
<None Pack="true" PackagePath="runtimes/win-x86/native/library32.dll" Update="library32.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Pack="true" PackagePath="runtimes/win-x64/native/library64.dll" Update="library64.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Pack="true" PackagePath="runtimes/linux-x64/native/liblibrary.so" Update="liblibrary.so">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
This works great with .NET Core apps on all supported platforms. Lately, though, we discovered issues using this library from .NET Framework apps - the runtime libraries aren't always copied over to referencing projects, leading to System.IO.FileNotFoundException exceptions. This appears to be related to this issue:
https://github.com/Microsoft/msbuild/issues/1582
As a workaround, we want to add a Framework 4.6.1 target to the package. If I just update the project file above, removing the TargetFramework property and adding
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
the project builds without errors, and the nupkg is created with net461 and netstandard2.0 folders under lib/, but none of the runtime files are included anymore. I can verify this by unzipping the .nupkg, but it's pretty obvious as the package size goes from about 2mb to about 20kb. I've tried adding conditionals to the ItemGroup like
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
But still nothing. What am I missing here?
I have a project folder in Visual Studio Code on Debian 9 with a Solution file that references two projects. When opening the folder, a banner appears saying "Some projects have trouble loading. Please review the output for more details". Viewing the output shows the following exception for the main WebAPI project:
[warn]: OmniSharp.MSBuild.MSBuildProjectSystem
Failed to load project file '/home/aidan/Projects/WebApiDemo/WebApiDemo/WebApiDemo.csproj'.
/home/aidan/Projects/WebApiDemo/WebApiDemo/WebApiDemo.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
The unit test project returns a similar The SDK 'Microsoft.NET.Sdk' specified could not be found.
All other answers to this type of question refer to a global.json file, which I don't have anywhere in my project - this was a new .NET Core 2 project, and not converted from an older version. Adding global.json does nothing. It was working at first, and I'm not sure what I changed to make it break. I do have the dotnet folder in my $PATH. The project file looks like this:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
Since I don't see any other explicit references to the SDK or its location in my project I'm stuck - any ideas what caused this to break?
Try to set MSBuildSDKsPath
export MSBuildSDKsPath=/opt/dotnet/sdk/2.2.105/Sdks
I am trying to build my software on Visual Studio Team Services. I recently upgraded from VS 2013 to VS 2015. I upgraded from the Azure 2.6 to the Azure 2.9 SDK. When the software builds, I get this error:
C:\a\src\CCC\Azure\CloudService1\CloudService1.ccproj (95, 0)
The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Windows Azure Tools\2.9\Microsoft.WindowsAzure.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
Is 2.9 not supported at this time? Here is my ccproj file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.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>
<ProductVersion>2.9</ProductVersion>
<ProjectGuid>XX</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CloudService1</RootNamespace>
<AssemblyName>CloudService1</AssemblyName>
<StartDevelopmentStorage>True</StartDevelopmentStorage>
<Name>CloudService1</Name>
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
<UseEmulatorExpressByDefault>False</UseEmulatorExpressByDefault>
</PropertyGroup>
<!-- Import the target files for this project template -->
<PropertyGroup>
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
<CloudExtensionsDir Condition=" '$(CloudExtensionsDir)' == '' ">$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Windows Azure Tools\2.9\</CloudExtensionsDir>
</PropertyGroup>
<Import Project="$(CloudExtensionsDir)Microsoft.WindowsAzure.targets" />
I found out that the XAML Build Definitions are being deprecated, so you cannot publish any builds higher than Azure SDK 2.8. You must upgrade to the hosted build:
In VS, go to team explorer > builds.
Under triggers, set it to manual. This will turn off the automatic XAML builds.
In Visual Studio Online, select your project.
Click builds.
Click the plus sign.
Select Visual Studio.
Create a new build definition.
We use Jenkins and msbuild to compile and package our software.
We've upgraded to Visual Studio 2012, which greatly improves the command line publishing functionality.
According to this: How do I configure MSBuild to use a saved publishProfile for WebDeploy?
I should be able to create the profile (I have, it working in VS2012 and deploys to C:\Built\PojectName) and in the jenkins job fire it off with:
msbuild myproj.csproj /p:DeployOnBuild=true;PublishProfile=Jenkins$Configuration.pubxml
Where $Configuration is Debug.
The build runs and finishes with "SUCCESS".
However, there is no Built folder created, there is a .zip file inside obj\debug
This is not what it's configured to do:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>C:\Built\blahblah</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>True</EnableUpdateable>
<DebugSymbols>True</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
</PropertyGroup>
</Project>
Further to that, if I deliberately munge the profile name to, say, NoSuchFile.pubxml, it still completes with success.
On the server we have Jenkins, .net 4.5, a recent Windows SDK and MS Web Deploy 2.0 installed.
Why is msbuild not picking up my publish profile?
I am trying to build .NET Framework 1.1 solution (VS 2003) on a TFS build server 2008 which is on windows server 2008 R2 machine. I am following the instructions from this website
http://blogs.msdn.com/b/nagarajp/archive/2005/10/26/485368.aspx
and going for the second solution suggested. The build server goes through the first 4 steps fine (Initializing build, Getting Sources, Labelling Sources and Compiling Sources for any cpu/release) but after then it just shows that Build in progress and does not do anything. I left the job running overnight and it still shows Buiid In progress. I checked the event log and it displays the following message:
The application (Visual Studio .NET 2003, from vendor Microsoft) has the following problem: Visual Studio .NET 2003 has a known compatibility issue with this version of Windows.
When i log in to the build server and then try opening Visual Studio 2003, it shows me a pop up window with the same message and then i have to click Run Program to go further. But since i am building the solution using command line, i am wondering how can i do that? I have also tried to run this program in compatibility mode (windows xp service pack 3) and checked the options "Disabe visual themes" and "Disable desktop composition" but no luck. Can anyone please help?
This is the modified version of the configuration file for 1.1 Framework project to get build with Build Server 2008 on Windows Server 2008 R2:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="DesktopBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<ProjectExtensions>
<ProjectFileVersion>2</ProjectFileVersion>
<Description></Description>
<BuildMachine>UNKNOWN</BuildMachine>
</ProjectExtensions>
<PropertyGroup>
<TeamProject>1.1 Framework</TeamProject>
<BuildDirectoryPath>UNKNOWN</BuildDirectoryPath>
<DropLocation>\\UNKNOWN\drops</DropLocation>
<RunTest>false</RunTest>
<RunCodeAnalysis>Never</RunCodeAnalysis>
<WorkItemType>Bug</WorkItemType>
<WorkItemFieldValues>System.Reason=Build Failure;System.Description=Start the build using Team Build</WorkItemFieldValues>
<WorkItemTitle>Build failure in build:</WorkItemTitle>
<DescriptionText>This work item was created by Team Build on a build failure. </DescriptionText>
<BuildlogText>The build log file is at:</BuildlogText>
<ErrorWarningLogText>The errors/warnings log file is at:</ErrorWarningLogText>
<UpdateAssociatedWorkItems>true</UpdateAssociatedWorkItems>
<AdditionalVCOverrides></AdditionalVCOverrides>
<CustomPropertiesForClean></CustomPropertiesForClean>
<CustomPropertiesForBuild></CustomPropertiesForBuild>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<ConfigurationToBuild Include="Release|Any CPU">
<FlavorToBuild>Release</FlavorToBuild>
<PlatformToBuild>Any CPU</PlatformToBuild>
</ConfigurationToBuild>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<PropertyGroup>
<VS2003_Devenv>C:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.com</VS2003_Devenv>
<VS2003_Configuration>Release</VS2003_Configuration>
</PropertyGroup>
<ItemGroup>
<VS2003_OutputFiles Include="$(SolutionRoot)\DSC.STARS\Main\DSC.STARS.Web\**\*.*" />
</ItemGroup>
<Target Name="AfterCompile">
<Exec Command=""$(VS2003_Devenv)" "$(SolutionRoot)\DSC.STARS\Main\DSC.STARS.SOLUTION.sln" /build release" />
<MakeDir Directories="$(BinariesRoot)\$(VS2003_Configuration)" Condition="!Exists('$(BinariesRoot)\$(VS2003_Configuration)')" />
<Copy SourceFiles="#(VS2003_OutputFiles)" DestinationFiles="#(VS2003_OutputFiles- >'$(BinariesRoot)\$(VS2003_Configuration)\%(RecursiveDir)%(Filename)%(Extension)')"/>
</Target>
</Project>