I have issues that I am dealing with where certain nuget installed package added via VS2012 have the copylocal value set to true where as others don't have any value set.
How does nuget know when to add copylocal and not to?
Is there some setting that I am missing in the nupkg file that I am missing?
I had a look at the source code for nuget (briefly) and it the copylocal value exists then it should be set to true.
e.g.
Install-Package System.Web.Mvc
resolves to
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll</HintPath>
</Reference>
However
Install-Package Newtonsoft.Json
Resolves to
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
I kind of figured this out.
The answer lies partly here:
http://msdn.microsoft.com/en-us/library/vslangproj.reference.copylocal
Although "Newtonsoft.Json" doesn't have the copylocal=true explicitly set in the csproj file, it seems the visual studio evaluates automatically when copylocal=true is set or not.
It seems nuget relies on the DTE integration to help it determine the value for copylocal.
I tested this out by running msbuild out of VS2012, removing System.Web.MVC from the GAC and it is copied to the bin dir.
I guess this only becomes an issue when one wants to open a compiled website the dll doesn't exist in the bin e.g. System.Web.MVC.
VS in this case does not know it should look in the GAC.
Related
I just created an azure pipeline from bitbucket cloud and using the default generated yaml file, when i run the Run New pipeline, I am getting errors in VsBuild saying
Error CS0246: The type or namespace name 'RestSharp' could not be found (are you missing a using directive or an assembly reference?)
The RestSharp.dll is located in my bin folder in asp.net website.
Looking at the raw logs, it says
2020-07-10T03:35:57.7771564Z Considered "d:\a\1\s\mywebsite\Bin\RestSharp.dll", but it didn't exist.
2020-07-10T03:35:57.7772002Z For SearchPath "{TargetFrameworkDirectory}".
2020-07-10T03:35:57.7772374Z Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\RestSharp.winmd", but it didn't exist.
2020-07-10T03:35:57.7772874Z Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\RestSharp.dll", but it didn't exist.
...
However, when I build in VS 2019, there are no build errors, since I am referencing my dlls and binaries.
How do I fix this missing dlls or referenced binaries? If I need to copy files from bin folder to the build directory, how?
Error CS0246: The type or namespace name 'RestSharp' could not be found
Tested using .dll file path in bin folder as HintPath. I encountered the same issue.
It seems that the root cause of this issue is that the RestSharp.dll doesn't exist in the Bin folder at the time of reference.
This is my solution to solve this issue:
Step1: Add the package reference in Packages.config file.
For example:
<?xml version="1.0" encoding="utf-8"?>
<packages>
.....
<package id="RestSharp" version="106.11.4" targetFramework="net472" />
</packages>
Step2: Change the RestSharp HintPath in .csproj file. Since you add the package reference, you could directly get the RestSharp.dll in the package path.
For example:
<Reference Include="RestSharp">
<Private>True</Private>
<HintPath>..\packages\RestSharp.106.11.4\lib\net452\RestSharp.dll</HintPath>
</Reference>
Then the RestSharp.dll could be used in the build.
By the way, I recommend that you could turn them into packages, and restore them during build. Then you could get the dll files in the package path. This can avoid the error above.
When I run nuget pack MyProject.csproj from the command line, I get the following error:
The replacement token 'author' has no value.
I checked my AssemblyInfo, and the AssemblyCompany is specified as "AJ Richardson". I tried manually replacing $author$ with AJ Richardson in my nuspec file, but then I got a slightly different error:
The replacement token 'description' has no value.
But the AssemblyDescription is also specified. It seems that NuGet is not reading anything from my AssemblyInfo. I have verified that AssemblyInfo is included in my project and the build action is set to Compile.
I have made a couple of NuGet packages before and did not have any issues. The only difference between this package and my previous packages is that this one has dependencies.
For reference, here is my nuspec:
<?xml version="1.0"?>
<package>
<metadata>
<id>$id$</id>
<version>1.0.0</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>https://github.com/my/repo/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/my/repo</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Initial release.</releaseNotes>
<copyright>Copyright AJ Richardson 2015</copyright>
<tags></tags>
</metadata>
<dependencies>
<dependency id="Newtonsoft.Json" version="6.0.1" />
</dependencies>
</package>
So my question is, why isn't NuGet reading my AssemblyInfo, and how do I convince it to do that?
I was also experiencing issues in this regard; my updates to AssemblyInfo didn't seem to be being picked up - despite me building and rebuilding, etc.
I was able to resolve the issue by explicitly telling NuGet to build (in my case in Release, with pdb symbols):
nuget pack foo.csproj -Build -Symbols -Properties Configuration=Release
I think the problem was that I hadn't built my project since modifying the AssemblyInfo. I did a rebuild and it's working now.
(As a side note, I also had the <dependencies> in the wrong section - it should be inside of <metadata> - but that was not causing the error in my question.)
Same problem here, but it turns out that someone introduced a signing key, and I was referencing assemblies that didn't have a strong name.
Weird that I didn't get a different error.
When I run "Inspect > Code Issues in Solution", R# tells me "Cannot resolve assembly System.Drawing" and points to this line of xml in a *.resx file:
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
I looked at my System.Drawing assembly in my project's list of References. It is version 3.5.0.0, not 2.0.0.0, so I changed the version number in the xaml in the .resx file from 2.0 to 3.5. That still elicited the same warning from R#, though.
So then I thought maybe it was the PublicKeyToken that was the culprit; so I changed that value from "b03f5f7f11d50a3a" to "969db8053d3322ac" (as found here); but then the project wouldn't even build; I got:
Invalid Resx file. The located assembly's manifest definition does not match the assembly reference.
Although these "issues" exist, the app seems to be working okay - the image that follows the assembly alias:
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
blee blah bloo
</value>
</data>
...displays fine.
Still, when R# raises its finger, it makes me nervous; how can I rectify this flubup?
NOTE: This is a Visual Studio 2008 Windows CE/Compact Framework app.
I had a similar problem in the resx file in one of my C# projects:
Once I installed the relevant reference (System.Windows.Forms etc) - for that project - that particular resharper issue went away:
Is NuGet suitable for pulling down assemblies which are not required for compilation, but are at runtime? I have a Visual Studio solution which contains a number of NuGet packages required for compilation - these packages are not kept in source control. At runtime there are a couple of extra dll's which are required. Would it be bad practice to create a VS post-build step which calls NuGet.exe to download these packages and then copies the binaries to the required location? It doesn't look like the intended use of NuGet, but I don't see any obvious flaws with this approach.
I not sure if this would be a good way to do it, but it might solve your problem:
Create a NuGet-package with the DLL's in question as content. You should have the following in your nuspec-file:
<files>
<file src="path\to\dll\one.dll" target="content\dlls\one.dll" />
<file src="path\to\dll\two.dll" target="content\dlls\two.dll" />
</files>
When installing this NuGet package in your project, you'll get a folder dlls added to the project root. You can then go to the property tab of all the included files and set Always for Copy to Output Directory.
I'm having difficulty implementing EFCodeFirst.CreateTablesOnly (changed to DontDropDbJustCreateTablesIfModelChangedStart).
I have successfully pulled in the package using NUGET. Now there is a mention of
in packages.config
and a DontDropDbJustCreateTablesIfModelChangedStart.cs
I've added Devtalk.EF.CodeFirst to references
in my app_start directory.
But I still can't make use of the DontDropDbJustCreateTablesIfModelChangedStart class. When I do, the app dies with msg
Could not load file or assembly 'EntityFramework, Version=4.1.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
When I check definition of DontDropDbJustCreateTablesIfModelChangedStart, I find it only has a signature and not a definition.
What did I do wrong? Or what step did I leave out? Am I supposed to Implement the Class/Method?
The problem is that library was probably compiled with EntityFramework.dll version 4.1.0.0 and author didn't update it for version 4.2.0.0 and 4.3.0.0. Try to redirect version 4.1.0.0 to version 4.3.0.0 in your web.config file.
Don't Use it use EF's Migrations:
http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-released.aspx